Skip to content

Cascader

When a dataset has a clear hierarchical structure (e.g., administrative regions, department structures, product categories), use the cascader for step-by-step selection.

Basic Usage

A widely applicable basic single-select cascader.

Value: []

Basic Usage

Initial Value

By binding an initial array to v-model, you can pre-select nodes in the Cascader.

Zhejiang / Hangzhou / West Lake District
Zhejiang / Hangzhou / Binjiang DistrictJiangsu / Nanjing / Xuanwu District

Value (Single): [ "zhejiang", "hangzhou", "xihu" ]

Value (Multiple): [ [ "zhejiang", "hangzhou", "binjiang" ], [ "jiangsu", "nanjing", "xuanwu" ] ]

Initial Value

Disabled

You can disable the entire component or specify certain options as unselectable in the data.

Zhejiang / Hangzhou / West Lake District

Value: []

Disabled

Multiple Select with Collapsed Tags

Set multiple to enable multi-select; use collapse-tags to collapse displayed tags.

Value: []

Multiple Select

Select Any Level

With check-strictly enabled, users can select nodes at any level.

Value: []

Select Any Level

Return Mode (emit-path)

By default, the full path array is returned. Set emit-path="false" to return only the selected node's value.

Zhejiang / Hangzhou / West Lake District

Value: xihu

Non-Path Mode

Search Filter

Enable filterable for quick search suggestions. Supports matching any segment in the full path.

Value: []

Searchable

Custom Content

Use the #default slot to fully customize menu item rendering.

Custom Slot

Custom Fields

Use the props attribute to specify the field names in the option object, such as value, label, children, etc.

Value: []

Custom Fields

Large Data Optimization

Enable virtual for virtual scrolling. Handles tens of thousands of nodes with smooth interaction.

Virtual Scroll

Use in Nuxt

The Cascader component fully supports SSR rendering in Nuxt 3/4. Components are auto-imported in Nuxt projects.

Use in Nuxt

SSR Notes:

  • ✅ Basic cascading level display fully supported
  • ✅ Multiple select and collapsed tags supported
  • ✅ Select any level (check-strictly) works in SSR
  • ✅ Search filter auto-enables after client activation
  • ✅ Virtual scroll supports initial render
  • 💡 Dropdown menus render via Teleport, not interfering with server-generated HTML

SSR Safety

Cascader's recursive node system is deeply optimized for SSR, ensuring strong consistency between server and client-generated node IDs and structures, effectively preventing hydration conflicts.

API

Props

PropDescriptionTypeDefault
model-value / v-modelBinding valuestring | number | (string | number)[] | (string | number)[][]
optionsData source of optionsCascaderOption[][]
propsConfiguration options, see table belowobject
placeholderInput placeholder textstring
disabledWhether disabledbooleanfalse
clearableWhether clearablebooleanfalse
sizeSize'large' | 'default' | 'small''default'
filterableWhether search filter is supportedbooleanfalse
filter-methodCustom filter method(node: CascaderOption, keyword: string) => boolean
separatorOption path separatorstring' / '
show-all-levelsWhether to show full path labelsbooleantrue
multipleWhether multi-select is enabledbooleanfalse
check-strictlyWhether to allow selecting any level nodebooleanfalse
expand-triggerSub-menu expand trigger'click' | 'hover''click'
emit-pathWhether to return path array when selection changesbooleantrue
collapse-tagsWhether to collapse tags in multi-selectbooleanfalse
collapse-tags-tooltipWhether to show tooltip for collapsed tagsbooleanfalse
max-collapse-tagsMax visible tags before collapsingnumber1
virtualWhether to enable virtual scrollbooleanfalse
virtual-item-heightVirtual scroll item heightnumber34
popper-classDropdown custom classstring
teleportedWhether to mount dropdown to bodybooleantrue
tag-typeMulti-select tag type'success' | 'info' | 'warning' | 'danger' | ''''
validate-eventWhether to trigger form validation on inputbooleantrue

CascaderOption

PropDescriptionTypeDefault
valueOption valuestring | number
labelOption labelstring
childrenChild options arrayCascaderOption[]
disabledWhether disabledbooleanfalse
leafWhether leaf nodeboolean

Cascader Config (props)

PropDescriptionTypeDefault
expandTriggerSub-menu expand trigger'click' | 'hover''click'
multipleWhether multi-selectbooleanfalse
checkStrictlyWhether to allow selecting any levelbooleanfalse
emitPathWhether to return path arraybooleantrue
valueProperty name for option valuestring'value'
labelProperty name for option labelstring'label'
childrenProperty name for child optionsstring'children'
disabledProperty name for disabled statestring'disabled'
leafProperty name for leaf nodestring'leaf'

Events

Event NameDescriptionParameters
changeTriggered when selection changes(value: any) => void
expand-changeTriggered when expanded node changes(value: any[]) => void
visible-changeTriggered when dropdown shows/hides(visible: boolean) => void
focusTriggered on focus(event: FocusEvent) => void
blurTriggered on blur(event: FocusEvent) => void
clearTriggered when clear button is clicked

Slots

Slot NameDescriptionParameters
defaultCustom node content{ node: CascaderOption, data: CascaderOption }
emptyContent when no matching data

Expose

NameDescriptionType
focusFocus the input() => void
blurBlur the input() => void
getCheckedNodesGet currently checked node objects(leafOnly?: boolean) => CascaderOption[]
inputRefInput DOM referenceHTMLInputElement

Theme Variables

VariableDescriptionDefault
--yh-cascader-heightCascader height32px
--yh-cascader-bg-colorBackground colorvar(--yh-fill-color-blank)
--yh-cascader-border-colorBorder colorvar(--yh-border-color)
--yh-cascader-border-color-hoverHover border colorvar(--yh-border-color-hover)
--yh-cascader-border-color-focusFocus border colorvar(--yh-color-primary)
--yh-cascader-text-colorText colorvar(--yh-text-color-regular)
--yh-cascader-placeholder-colorPlaceholder colorvar(--yh-text-color-placeholder)
--yh-cascader-node-heightOption node height34px
--yh-cascader-node-bg-color-hoverOption hover backgroundvar(--yh-fill-color-light)
--yh-cascader-node-bg-color-activeOption active backgroundvar(--yh-fill-color-light)
--yh-cascader-node-text-color-activeOption active text colorvar(--yh-color-primary)
--yh-cascader-menu-min-widthMenu min width180px
--yh-cascader-menu-max-heightMenu max height274px

Released under the MIT License.