Skip to content
Alea0.1

Forms

Cascader

Pick from nested options column by column: country, then city.

Ant Design: Cascader

import { Cascader } from '@alea/ui';

Examples

Cascader

Arrow right or Enter opens the next level.

CityWhere you work from

Props

Cascader props

Pick from nested options column by column: country, then city (Ant's Cascader).

PropTypeDefaultDescription
optionsrequiredCascaderOption[]-The tree of options: id, label, children.
allowsParentSelectionboolean-Lets people pick a parent too, not only the last level.
defaultValueKey[]-The path of ids to start with.
descriptionReactNode-Help text shown under the field.
isDisabledboolean-Disables every part of it.
labelReactNode-The visible label.
onChange((path: Key[], options: CascaderOption[]) => void)-Called with the path of ids.
placeholderstring'Select…'Shown while there is no value.
valueKey[]-The picked path of ids (controlled).

Accessibility

  • Each column is a listbox named after its parent.

Keyboard

KeyDoes
Arrow Up / DownMove in a column
Arrow Right or EnterOpen the next level
Arrow LeftBack to the previous level
EscapeClose

Do and don't

Do

  • Use it for deep but predictable hierarchies (country, state, city).
  • Show the whole path in the trigger.

Don't

  • Don't use it for more than four levels.
  • Don't use it when people know the leaf name: use Autocomplete.
Tested with axe, keyboard and screen reader roles