Command Palette

Search for a command to run...

Cascader

A column-based cascading dropdown for selecting a path through hierarchical data (region → city → district, category trees). Desktop popover / mobile drawer, keyboard navigable, controlled or uncontrolled, with clear and custom display rendering.

A column-based cascading dropdown for picking a path through hierarchical data — regions, category trees, org charts. Each level opens the next column to its right; choosing a leaf commits the full path. The value is the array of option values from root to leaf. It is uncontrolled by default (defaultValue) or fully controlled via value + onChange. On small screens it switches from a popover to a bottom drawer automatically.

Installation

One-time setup: add the @ikui registry to your components.json.

components.json
{
  "registries": {
    "@ikui": "https://ik-ui.pages.dev/r/{name}.json"
  }
}

Then install the component:

pnpm dlx shadcn@latest add @ikui/cascader

Usage

import { Cascader, type CascaderOption } from "@/components/cascader";
const options: CascaderOption[] = [
  {
    value: "zhejiang",
    label: "Zhejiang",
    children: [{ value: "hangzhou", label: "Hangzhou" }],
  },
];

<Cascader
  options={options}
  onChange={(value, selected) => console.log(value, selected)}
/>;

Examples

Controlled value

Pass value and onChange to control the selection. onChange reports both the value path and the matching CascaderOption[].

Expand on hover

Set expandTrigger="hover" to open child columns on mouse-over instead of click. A leaf still requires a click to commit.

Disabled options

Mark any option disabled to make it (and its branch) unselectable. Here allowClear is also turned off, so there is no clear button.

Custom display

Use displayRender to control how the selected path renders in the trigger — here it shows only the leaf label instead of the full a / b / c path.

Props

PropTypeDefault
options
CascaderOption[]
-
value
string[]
-
defaultValue
string[]
-
onChange
(value: string[], selectedOptions: CascaderOption[]) => void
-
placeholder
string
"Please select"
disabled
boolean
false
allowClear
boolean
true
expandTrigger
"click" | "hover"
"click"
displayRender
(labels: string[], selectedOptions: CascaderOption[]) => React.ReactNode
-
className
string
-
popupClassName
string
-

CascaderOption

PropTypeDefault
value
string
-
label
React.ReactNode
-
textLabel
string
-
disabled
boolean
-
children
CascaderOption[]
-