Cascader
Hierarchical single or multiple selector with local search and lazy child loading.
Cascader
TxCascader selects a path from nested options. Single mode stores one path array, while multiple mode stores an array of path arrays. Search is local to the loaded option tree; async children are loaded through load when a non-leaf node without children is expanded.
Basic Usage
Cascader
Demo will load when visible.
Notes
- Single-select
modelValueis a path array; multi-select is an array of path arrays. expandTriggercontrols click/hover expansion (inhovermode, clicking non-leaf nodes will not expand).- Async
loadonly triggers when a node has nochildrenand is not markedleaf.
API
TxCascader Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue | CascaderValue | - | Selected value. Single mode uses one path array; multiple mode uses an array of path arrays. |
options | CascaderNode[] | [] | Root option tree rendered by the cascader columns. |
multiple | boolean | false | Enables selecting multiple leaf paths and renders selected paths as tags. |
disabled | boolean | false | Disables the trigger, clear button, node selection, and keyboard open behavior. |
placeholder | string | '请选择' | Placeholder text shown when no path is selected. |
searchable | boolean | true | Shows a local search input that filters loaded leaf paths by formatted label. |
clearable | boolean | true | Shows the clear button when a value is selected and the component is enabled. |
placement | PopoverPlacement | 'bottom-start' | Placement forwarded to the underlying TxPopover. |
dropdownOffset | number | 6 | Offset forwarded to the underlying TxPopover. |
dropdownWidth | number | 360 | Width forwarded to the underlying TxPopover. |
dropdownMaxWidth | number | 520 | Maximum width forwarded to the underlying TxPopover. |
dropdownMaxHeight | number | 340 | Maximum panel height in px. |
expandTrigger | 'click' | 'hover' | 'both' | 'both' | Controls how non-leaf nodes expand; hover ignores click expansion for branch nodes. |
load | (node, level) => Promise<CascaderNode[]> | - | Lazily loads children for a non-leaf node that does not already provide children. |
CascaderNode
| Field | Type | Description |
|---|---|---|
value | string | number | Stable node key used to build selected paths. |
label | string | Text rendered in columns, selected tags, and local search results. |
disabled | boolean | Prevents expanding or selecting this node. |
leaf | boolean | Marks the node as selectable and prevents lazy loading. |
children | CascaderNode[] | Child nodes rendered in the next column when this branch is active. |
CascaderValue
- Single select:
CascaderPath(Array<string | number>) - Multi select:
CascaderPath[]
Events
| Event | Params | Description |
|---|---|---|
update:modelValue | (v) | Emitted with the next CascaderValue whenever selection or clear changes the value. |
change | (v) | Mirrors value changes for consumers that do not use v-model. |
open | - | Emitted after the dropdown opens. |
close | - | Emitted after the dropdown closes. |
Expose
| Name | Type | Description |
|---|---|---|
open() | () => void | Opens the dropdown. |
close() | () => void | Closes the dropdown. |
toggle() | () => void | Toggles the dropdown open state. |
focus() | () => void | Focuses the trigger element. |
blur() | () => void | Blurs the trigger element. |
clear() | () => void | Clears to undefined in single mode or [] in multiple mode. |
setValue(v) | (v) => void | Emits update:modelValue and change with the supplied value. |
getValue() | () => any | Returns the current modelValue prop. |