Skip to main content

Cascader

A multi-level cascading selector with controlled / uncontrolled modes, multiple selection, selecting at any level, path echo, search filtering, and keyboard navigation.

Basic usage​

Controlled cascading selection

Current value: (not selected)

import { useState } from 'react'
import { LhCascader } from '@lh-ui/react'
import type { LhCascaderNode } from '@lh-ui/react'

const options: LhCascaderNode[] = [
{
label: 'Zhejiang',
value: 'zhejiang',
children: [
{
label: 'Hangzhou',
value: 'hangzhou',
children: [{ label: 'West Lake', value: 'xihu' }],
},
],
},
{
label: 'Jiangsu',
value: 'jiangsu',
children: [
{
label: 'Nanjing',
value: 'nanjing',
children: [{ label: 'Fuzimiao', value: 'fuzimiao' }],
},
],
},
]

export default function Demo() {
const [value, setValue] = useState<(string | number)[]>([])

return (
<LhCascader
value={value}
options={options}
placeholder="Select a region"
onChange={(next) => setValue(next)}
/>
)
}

Cascader Props​

PropDescriptionTypeOptionsDefault
valueControlled value (array of path values)(string | number)[]——
defaultValueUncontrolled default value(string | number)[]——
optionsCascading option treeLhCascaderNode[]—[]
placeholderPlaceholderstring—Locale pack fallback
disabledWhether to disableboolean—false
readonlyRead-onlyboolean—false
clearableWhether to be clearableboolean—true
sizeSize'small' | 'medium' | 'large'—Follows ConfigProvider
showAllLevelsWhether the echo shows the full pathboolean—true
checkStrictlyAllow selecting any nodeboolean—false
emitPathWhether the value carries the full pathboolean—true
multipleMultiple selectionboolean—false
cascadingExpand children on hoverboolean—true
separatorPath separatorstring—'/'
collapseTagsCollapse multiple-selection tagsboolean—false
filterableWhether to be searchableboolean—false
itemConfigCustom field aliasesLhCascaderItemConfig—{}
ariaLabelAccessibility labelstring——
placementPanel placementLhPlacement—'bottom-start'
sxShorthand layout propsSxProps——

LhCascaderNode​

PropDescriptionType
labelNode display textstring
valueNode valuestring | number
disabledDisable this nodeboolean
leafLeaf marker (explicitly declares whether the node is a leaf)boolean
childrenChild nodesLhCascaderNode[]

Cascader events​

EventDescriptionCallback signatureVue equivalent
onChangeFired on selection change (the value plus the full node path; the path is null for multiple selection / clearing)(value: (string | number)[], path: LhCascaderNode[] | null) => void@change
onClearFired when cleared() => void—

Keyboard interaction​

The trigger is role="combobox": ArrowDown / ArrowUp open the panel and move focus to the first / last column, and Escape collapses it and returns focus to the input. The panel is role="dialog", and each column is a role="listbox": Up / Down move within a column (skipping disabled items), Right expands / enters the next column, Left goes back to the previous column, and Enter / Space act like a click. In multiple mode, pressing Backspace on an empty input removes the last selected item.

ref​

forwardRef<HTMLDivElement> — the trigger root element. LhCascaderInstance exposes open() / close() / toggle() / clear() / isOpen.

Styles​

import '@lh-ui/react/style/cascader'