Skip to main content

Cascader

import { Cascader } from '@enmovil/ui-design-system';

A select for choosing a value from a hierarchy, such as region, state and city, by drilling down level by level. It supports search, selecting several values, and choosing a parent level as the value.

Properties​

PropertyTypeRequiredDefaultAllowed valuesDescription
multiplebooleanNo——Lets the user check several values, each shown as a tag. Tags that do not fit collapse into "+ N more", with the rest listed in a tooltip.
sizestringNo'middle''small', 'middle', 'large'Height of the select box: small (28px), middle (34px) or large (40px), as in Select. Defaults to middle.
disabledbooleanNo——Greys out the cascader and stops it from opening.
optionsOptionType[]No——The hierarchy to choose from. Each option has a value and label, and optionally children, disabled, and isLeaf: false for children loaded later with loadData.
statusstringNo—'', 'error', 'warning'Validation state of the select box: error or warning.
styleCSSPropertiesNo——Inline styles of the select box, for example its width.
defaultValueValueType<Required<OptionType>, keyof OptionType>[] | ValueType<Required<OptionType>, keyof OptionType>[][]No——Initially selected path when uncontrolled, as the values from the top level down, for example ["south", "karnataka", "bengaluru"]. With multiple, an array of such paths.
changeOnSelectbooleanNo——Lets any level be the value, not only a leaf, so the value changes at each level the user clicks.
showCheckedStrategystringNo—'SHOW_PARENT', 'SHOW_CHILD'With multiple, which checked items appear as tags: SHOW_PARENT (the default) shows a parent in place of its children once all are checked, SHOW_CHILD shows each checked leaf.
expandTriggerstringNo—'hover', 'click'How sub-menus open: click (the default) or hover.
showSearchboolean | ShowSearchType<OptionType, keyof OptionType>No——Adds a search box that filters every path by the typed text.
placeholderReactNodeNo——Text shown while nothing is selected.
allowClearboolean | { clearIcon?: RenderNode; }No——Shows a clear icon over a selected value. On by default; set false to hide it.
Other attributes

Cascader passes 121 further attributes through to the underlying element. They aren't part of the supported API and may change between releases, so use only the properties listed on this page.

Events​

NameSignatureWhen it fires
onDropdownVisibleChange((visible: boolean) => void)Fires when the menus open or close.
onFocusFocusEventHandler<HTMLElement>Fires when the cascader receives focus.
onBlurFocusEventHandler<HTMLElement>Fires when the cascader loses focus.
onChange((value: ValueType<Required<OptionType>, keyof OptionType>[], selectOptions: OptionType[]) => void) | ((value: ValueType<Required<OptionType>, keyof OptionType>[][], selectOptions: OptionType[][]) => void)Fires when the selected path changes, with the value path and the matching options.
onSearch((value: string) => void)Fires as the user types in the search box. Requires showSearch.
displayRender((label: string[], selectedOptions?: OptionType[]) => ReactNode)Formats the selected path shown in the box. Called with the labels of the path; without it they are joined with " / ".

Children​

Cascader does not accept children.

Variants​

Loading examples…

Playground​

Change the controls to see how the properties affect the component. Values the controls don't cover come from the Default example.

Loading playground…

Storybook​

Open Cascader in Storybook to try every story with the full set of controls.