Examples

Country, region, city

The trigger shows the path; the form submits the leaf value.

Preview
Office

Country, region, then city.

Example.tsx
import { Cascader, type CascaderOption } from '@reactloom/ui';
import { useState } from 'react';

const places: CascaderOption[] = [
  {
    value: 'in',
    label: 'India',
    children: [
      { value: 'mh', label: 'Maharashtra', children: [{ value: 'mumbai', label: 'Mumbai' }, { value: 'pune', label: 'Pune' }] },
      { value: 'ka', label: 'Karnataka', children: [{ value: 'bengaluru', label: 'Bengaluru' }, { value: 'mysuru', label: 'Mysuru' }] },
    ],
  },
  { value: 'jp', label: 'Japan', children: [{ value: 'tokyo', label: 'Tokyo' }, { value: 'osaka', label: 'Osaka' }] },
  { value: 'de', label: 'Germany', children: [{ value: 'berlin', label: 'Berlin' }, { value: 'munich', label: 'Munich', disabled: true }] },
];

export default function Example() {
  const [value, setValue] = useState<string | null>('pune');
  return (
    <div style={{ width: '100%', maxWidth: 320 }}>
      <Cascader label="Office" options={places} value={value} onValueChange={setValue} name="office" description="Country, region, then city." />
    </div>
  );
}

Leaf only

showLeafOnly shows just the chosen item.

Preview
Category
Example.tsx
import { Cascader } from '@reactloom/ui';

export default function Example() {
  return (
    <div style={{ width: '100%', maxWidth: 320 }}>
      <Cascader
        label="Category"
        showLeafOnly
        defaultValue="laptops"
        options={[
          { value: 'electronics', label: 'Electronics', children: [{ value: 'laptops', label: 'Laptops' }, { value: 'phones', label: 'Phones' }] },
          { value: 'home', label: 'Home', children: [{ value: 'kitchen', label: 'Kitchen' }, { value: 'garden', label: 'Garden' }] },
        ]}
      />
    </div>
  );
}

API reference

Cascader props
PropTypeDefault
optionsrequired
{ value, label, children?, disabled?, icon? }; leaves are the values.
CascaderOption[]—
value / defaultValue
The chosen leaf.
string | null—
onValueChange
(value, path) => void—
separator
string' / '
showLeafOnly
booleanfalse
name
Submitted as a hidden input.
string—
label · description · error · required · disabled · size · placeholder
As on Select.
—
classNames · styles
root, label, description, trigger, value, indicator, error.
Partial<Record<CascaderSlot, …>>—

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

Slot class names

Add classes to inner parts with classNames (className is shorthand for root): root, label, description, trigger, value, indicator, error.

Accessibility

  • A menu button: the trigger’s name includes the label and the current path.
  • Each level is a submenu; → opens it, ← returns, Enter chooses a leaf.
Keyboard interactions
KeyAction
Enter / Space / ↓Open the first level
↑ / ↓Move
→Open the next level
←Back to the previous level
EnterChoose a leaf
EscapeClose

Usage guidelines

Do

  • Use for three or more levels where each choice narrows the next.

Don’t

  • Don’t use for flat lists; use Select or Combobox.
  • For searching deep trees, use TreeSelect with searchable.