Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Buttons

  • Button
  • ShimmerButton
  • InteractiveHoverButton
  • RainbowButton
  • PulsatingButton
  • RippleButton
  • ButtonGroup
  • SocialButton

Basic Inputs

  • Input
  • Textarea
  • CellEditor
  • Select
  • Checkbox
  • CheckboxGroup
  • Radio
  • Switch
  • Toggle
  • Segmented
  • Slider
  • NumberField
  • ElasticSlider

Advanced Inputs

  • MathTextarea
  • QuestionEditor
  • QuestionAnswer
  • MathField
  • SecretField
  • PasswordGenerator
  • Combobox
  • RemoteSelect
  • Listbox
  • Mentions
  • InputOTP
  • Rating
  • Upload
  • RegionSelect
  • ImageCropper
  • ScopeMatrix
  • Transfer
  • Cascader
  • TreeSelect
  • RegionCascader
  • CountrySelect
  • MarkdownEditor
  • Novel editor
  • RichTextEditor
  • CodeEditor
  • IssueReporter
  • ColorPicker
  • ColorField
  • ColorSwatchPicker
  • Choicebox
  • EmojiPicker
  • VoiceRecord
  • IconPicker
  • InspectorPanel

Date and Time

  • Calendar
  • DatePicker
  • DateTimePicker
  • DateRangePicker
  • TimePicker
  • TimeField

Form Frameworks

  • Form
  • ModalForm / DrawerForm
  • ProForm
  • StepsForm
  • LoginForm
  • AuthPanel
  • ClickCaptcha
  • Label
  • Field
  • SearchForm

Cascader

cascader

Selects a value through linked hierarchical option columns.

Usage

Basic usage

Click to expand step by step and select the leaf node to submit the entire path. When it is not controlled, use defaultValue to set the initial value.

tsx
<Cascader
  nodes={nodes}
  placeholder="Select region"
  onChange={(path, nodePath) => setValue(path)}
/>

hover Expand

expandTrigger="hover" will be expanded column by column when moved in. Click to submit.

tsx
<Cascader nodes={nodes} expandTrigger="hover" placeholder="Select Region" />

Any layer optional

changeOnSelect allows you to select any level (not necessarily the leaf) and submit it.

tsx
<Cascader nodes={nodes} changeOnSelect placeholder="Select region" />

Default vs. searchable

defaultValue echo path; showSearch A search box appears at the top of the floating layer and enter the direct link to the leaf.

tsx
<Cascader
  nodes={nodes}
  defaultValue={["zhejiang", "hangzhou", "xihu"]}
  showSearch
/>

Disabled

tsx
<Cascader nodes={nodes} disabled placeholder="Select region" />

When to use

Use Cascader for hierarchical choices such as province/city/district, category/subcategory, or organizational levels, where the user drills down to select a complete path. Its value is an array of node key values from the root to the selected node. By default, only leaves can be selected; enable changeOnSelect to accept a node at any level. For a flat option list, use Combobox or Listbox instead.

Import

ts
import { Cascader, flattenLeafPaths, filterLeafPaths, type CascaderLeafPath } from "@hulianui/ui"

Props

NameTypeDefaultDescription
nodes*TreeNode[]-Hierarchical data using the shared tree-core TreeNode shape: key, label, children, and disabled.
valuestring[]-Controlled key path from the root to the selected node.
defaultValuestring[][]Initial key path when uncontrolled.
expandTrigger"click" | "hover""click"Interaction that expands the next level.
changeOnSelectbooleanfalseWhether a node at any level can be selected instead of leaves only.
showSearchbooleanfalseShows a search field above the popup. Leaf paths are flattened for fuzzy matching, and selecting a result submits its full path.
searchPlaceholderstring"\u641c\u7d22\u2026"Search-field placeholder; the built-in Chinese copy means “Search…”.
placeholderstring"\u8bf7\u9009\u62e9"Trigger placeholder; the built-in Chinese copy means “Please select.”
disabledboolean-Disables the component.
invalidboolean-Applies invalid-state styling.
size"sm" | "md" | "lg""md"Trigger size.
classNamestring-Additional class name for the container.

Events

EventTypeDescription
onChange(path: string[], nodes: TreeNode[]) => voidCalled with the selected key path and its corresponding node chain.

Usage guidelines

  • value is a complete key-path array, such as ["zhejiang","hangzhou","xihu"], not a single leaf key. Provide the full path when restoring a value so the expanded columns align correctly.
  • A disabled node cannot be selected, and its subtree cannot be expanded through that node.
  • The second onChange argument is the selected TreeNode[] chain. Use it to display labels instead of looking the nodes up again.
  • The trigger is a role="combobox" button, and native attributes that are not listed in Props (aria-*, data-*, id, title, onBlur, …) land on it rather than on the outer container, which is the element that takes focus and that screen readers announce (#293).
  • Inside Field the label's htmlFor, aria-describedby, invalid, and disabled are wired to the trigger automatically, and so is the aria-required injected by <Field required>. That chain was broken before 0.54.0 (the label pointed at an id that did not exist, so screen readers never announced the field name); upgrading needs no call-site change.
  • Query the trigger by role with getByRole("combobox") in tests, not "button" anymore.

Related

SecretField · Combobox · Listbox · Mentions · InputOTP · Rating

Playground

<Cascader
  nodes={nodes}
  expandTrigger="click"
  value={value}
  onChange={(path) => setValue(path)}
/>
PreviousTransferFormsNextTreeSelect

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Usage guidelines
    • Related
  • Playground