Skip to content

Cascader ​

A Neo-Brutalist styled cascading dropdown selection component. It displays multi-level hierarchical options in grid-cascaded panels, supporting path binding (single/multiple select), parent-child relation control, and complete keyboard interactions.

Item interaction ​

The current item, navigation ancestors, selected paths, and aggregate parent checkbox states are distinct. Ancestor arrows retain the path cue while the current item receives the full-row highlight. Classic uses lemon yellow with black text; other presets retain their own highlight pairs. See theme customization.

Preview ​

Preview
当前值: 空
当前值: 空
当前值: 空

Installation ​

pnpm dlx brutx-vue@latest add cascader

Usage ​

Basic Usage ​

vue
<script setup>
import { ref } from 'vue'
import { Cascader } from 'brutx-ui-vue'

const options = [
    {
        value: 'us',
        label: 'USA',
        children: [
            {
                value: 'ny',
                label: 'New York',
                children: [
                    { value: 'man', label: 'Manhattan' },
                    { value: 'qns', label: 'Queens' },
                ]
            },
            {
                value: 'ca',
                label: 'California',
            }
        ]
    },
    {
        value: 'cn',
        label: 'China',
        children: [
            { value: 'bj', label: 'Beijing' },
            { value: 'sh', label: 'Shanghai' },
        ]
    }
]

const selected = ref([])
</script>

<template>
    <Cascader
        v-model="selected"
        :options="options"
        placeholder="Select region"
        clearable
    />
</template>

Multiple Selection ​

Set the multiple attribute to enable multi-select. The v-model bound value will be a two-dimensional array representing the selected full path arrays. By default, checking a parent node checks all its descendant leaf nodes.

vue
<script setup>
import { ref } from 'vue'
import { Cascader } from 'brutx-ui-vue'

const selected = ref([]) // e.g. [['us', 'ny', 'man'], ['cn', 'bj']]
</script>

<template>
    <Cascader
        v-model="selected"
        :options="options"
        multiple
        placeholder="Select multiple regions"
    />
</template>

Check Strictly (Any level selection) ​

By default, only leaf nodes can be selected. Set checkStrictly to true to allow selecting nodes of any level (parent nodes can be bound as paths).

vue
<template>
    <Cascader
        v-model="selected"
        :options="options"
        check-strictly
        placeholder="Select any level"
    />
</template>

Asynchronous Option Updates ​

The trigger's labels and count and the panel's selection indicators use complete paths that match the current options at every level and are valid for the current selection mode. Leaf paths are valid by default. With checkStrictly enabled, parent paths are valid too.

When options updates asynchronously, temporarily unavailable paths stay in v-model. Updating the options alone emits neither update:modelValue nor change. Selection reappears when the options return and the path is still in the model. In multiple mode, checking or unchecking a parent only affects paths currently available for selection. Clearing removes every path in the model, and choosing a new path in single mode replaces the previous one.

API Reference ​

Cascader — Props
NameTypeDefaultDescription
options
Required
CascaderOption<unknown>[]
—
The nested option tree for cascading selection; each option uses value and label and may include children.
Details

Declared type

CascaderOption<unknown>[]

Referenced types

CascaderOption
Type definition — CascaderOption
export interface CascaderOption<T = unknown> {
    value: CascaderValue
    label: string
    children?: CascaderOption<T>[]
    disabled?: boolean
    data?: T
}

Default value details

Not declared
—

Source

Cascader.vue:27

packages/ui/src/components/cascader/Cascader.vue

modelValue
CascaderValue[] | CascaderValue[][] | undefined
[]

Factory evaluated per instance

The selected paths, bound with v-model. Single mode uses one CascaderValue path; multiple mode uses an array of paths.
Details

Declared type

CascaderValue[] | CascaderValue[][] | undefined

Referenced types

CascaderValue
Type definition — CascaderValue
export type CascaderValue = string | number

Default value details

Resolved value
[]

Source

Cascader.vue:29

packages/ui/src/components/cascader/Cascader.vue

open
boolean | undefined
undefined
The controlled open state of the dropdown panel, synchronized with v-model:open.
Details

Declared type

boolean | undefined

Literal values

  • false
  • true

Default value details

Resolved value
undefined

Source

Cascader.vue:31

packages/ui/src/components/cascader/Cascader.vue

multiple
boolean | undefined
false
Allows selecting multiple option paths; modelValue is an array of paths when enabled.
Details

Declared type

boolean | undefined

Literal values

  • false
  • true

Default value details

Resolved value
false

Source

Cascader.vue:33

packages/ui/src/components/cascader/Cascader.vue

clearable
boolean | undefined
false
Shows a clear action that removes all bound paths, including temporarily unavailable paths.
Details

Declared type

boolean | undefined

Literal values

  • false
  • true

Default value details

Resolved value
false

Source

Cascader.vue:35

packages/ui/src/components/cascader/Cascader.vue

checkStrictly
boolean | undefined
false
Allows parent nodes with children to be selected without requiring a leaf node.
Details

Declared type

boolean | undefined

Literal values

  • false
  • true

Default value details

Resolved value
false

Source

Cascader.vue:37

packages/ui/src/components/cascader/Cascader.vue

separator
string | undefined
" / "
Sets the separator displayed between labels in a path on the trigger.
Details

Declared type

string | undefined

Default value details

Resolved value
" / "

Source

Cascader.vue:39

packages/ui/src/components/cascader/Cascader.vue

maxDisplay
number | undefined
2
In multiple mode, the maximum number of paths shown directly in the trigger. Above this limit, the trigger shows the total number of currently matching selected paths.
Details

Declared type

number | undefined

Default value details

Resolved value
2

Source

Cascader.vue:41

packages/ui/src/components/cascader/Cascader.vue

size
"default" | "lg" | "sm" | undefined
"default"
Sets the trigger button size variant.
Details

Declared type

"default" | "lg" | "sm" | undefined

Literal values

  • "default"
  • "lg"
  • "sm"

Default value details

Resolved value
"default"

Source

Cascader.vue:43

packages/ui/src/components/cascader/Cascader.vue

placeholder
string | undefined
undefined
Text shown in the trigger when no selected path matches the current options.
Details

Declared type

string | undefined

Default value details

Resolved value
undefined

Source

Cascader.vue:45

packages/ui/src/components/cascader/Cascader.vue

disabled
boolean | undefined
false
Disables user interaction with the select trigger and dropdown panel.
Details

Declared type

boolean | undefined

Literal values

  • false
  • true

Default value details

Resolved value
false

Source

Cascader.vue:47

packages/ui/src/components/cascader/Cascader.vue

dropdownClass
string | undefined
undefined
CSS classes added to the cascader dropdown panel.
Details

Declared type

string | undefined

Default value details

Resolved value
undefined

Source

Cascader.vue:49

packages/ui/src/components/cascader/Cascader.vue

class
string | undefined
undefined
CSS classes added to the select trigger button.
Details

Declared type

string | undefined

Default value details

Resolved value
undefined

Source

Cascader.vue:51

packages/ui/src/components/cascader/Cascader.vue

ariaLabel
string | undefined
undefined
The explicit accessible name of the trigger; ariaLabelledby takes precedence, followed by an associated visible label, then the placeholder fallback.
Details

Declared type

string | undefined

Default value details

Resolved value
undefined

Source

Cascader.vue:53

packages/ui/src/components/cascader/Cascader.vue

id
string | undefined
undefined
The DOM ID of the native trigger button, allowing a visible label to be associated through its for attribute.
Details

Declared type

string | undefined

Default value details

Resolved value
undefined

Source

Cascader.vue:55

packages/ui/src/components/cascader/Cascader.vue

ariaLabelledby
string | undefined
undefined
The ID of the associated name element; it takes precedence over ariaLabel, a visible label, and the placeholder fallback.
Details

Declared type

string | undefined

Default value details

Resolved value
undefined

Source

Cascader.vue:57

packages/ui/src/components/cascader/Cascader.vue

Cascader — Events
NameSignature or typeDescription
@update:modelValue
[value: CascaderValue[] | CascaderValue[][]]
Emits the updated path value when selection changes, for synchronizing the controlled value with v-model.
Details

Declared type

[value: CascaderValue[] | CascaderValue[][]]

Referenced types

CascaderValue
Type definition — CascaderValue
export type CascaderValue = string | number

Source

Cascader.vue

packages/ui/src/components/cascader/Cascader.vue

@update:open
[value: boolean]
Emits the new boolean when the dropdown open state changes and can be used with v-model:open.
Details

Declared type

[value: boolean]

Literal values

  • false
  • true

Source

Cascader.vue

packages/ui/src/components/cascader/Cascader.vue

@change
[value: CascaderValue[] | CascaderValue[][]]
Emits the selected single path or set of paths when the user changes the selection.
Details

Declared type

[value: CascaderValue[] | CascaderValue[][]]

Referenced types

CascaderValue
Type definition — CascaderValue
export type CascaderValue = string | number

Source

Cascader.vue

packages/ui/src/components/cascader/Cascader.vue

@open-change
[open: boolean]
Emits the current open state when the dropdown panel opens or closes.
Details

Declared type

[open: boolean]

Literal values

  • false
  • true

Source

Cascader.vue

packages/ui/src/components/cascader/Cascader.vue

Data Types ​

ts
type CascaderValue = string | number

interface CascaderOption<T = unknown> {
    value: CascaderValue
    label: string
    children?: CascaderOption<T>[]
    disabled?: boolean
    data?: T
}

CascaderOption supports a generic for the business data type: in CascaderOption<MyData>[] the data field gets type inference; it defaults to unknown to stay permissive.

Exported Types ​

ts
import type { CascaderOption, CascaderValue } from 'brutx-ui-vue'

Accessibility ​

  • Clear action: The trigger and clear action are separate buttons that share shell movement, keeping their relative positions during hover and press. Focusing the trigger reveals the clear button for Tab navigation; clearing returns focus to the trigger.

  • Keyboard Interaction:

    • ArrowDown / ArrowUp: Move focus up and down within the active column, skipping disabled options
    • ArrowRight: Expand the focused option's sub-column and focus the first item
    • ArrowLeft: Collapse the active sub-column, returning to parent option column
    • Enter / Space: Select option, or toggle Checkbox state in multi-select mode
    • Escape: Close dropdown panel
  • ARIA Attributes: The trigger has role="combobox", aria-expanded and aria-disabled indicators. Option items have role="menuitem"

  • Name association: The native trigger button supports a visible Label associated through id and for. Name priority is ariaLabelledby, ariaLabel, associated visible Label, then the current placeholder. The placeholder is exposed through the native title fallback, which also shows the browser hover tooltip.

  • Focus Management: Upon opening, focus moves to the last selected value's option item; with no selected value no item is highlighted (aria-activedescendant stays undefined) until keyboard navigation begins, avoiding misreporting the first option while focus is still on the trigger

  • Reduced Motion: Transition animations support prefers-reduced-motion settings and automatically downgrade (if applicable)

Brute force builds.