Cascader
Select a path from hierarchical data with cascading columns
Source
LLM docs
Docs
Package
Usage
Cascader lets users select a value from hierarchical data: picking an option in one column
reveals its children in the next column. The value is a path from the root option to the
selected one, for example ['asia', 'jp', 'tokyo'].
All demos on this page switch to the flat list layout on small screens, open them on a larger screen to see the columns.
Data prop
Data passed to the data prop is an array of CascaderOption objects:
- Each option must have a unique
valueacross the whole data tree labelis optional,valueis used when it is not setchildrencontains an array of nested optionsdisabledprevents an option from being selected or expanded
Value and onChange
Cascader value is an array of option values or null when nothing is selected.
onChange is called with the selected path and the corresponding CascaderOption objects:
By default, only leaf options (options without children) can be selected. Clicking a parent option only expands the next column.
Change on select
Set the changeOnSelect prop to allow selecting any option, not only leaves. Clicking a parent
option then both selects it and expands the next column:
Close on select
closeOnSelect controls whether the dropdown is closed after a value is selected. By default,
the dropdown stays open, unless allowDeselect is set to false:
Allow deselect
By default, clicking the selected option again removes the value. Set allowDeselect={false} to
disable this behavior:
Expand trigger
By default, the next column is opened when an option is clicked. Set expandTrigger="hover"
to open the next column on hover instead – selecting a leaf still requires a click:
With expandTrigger="hover", the open column stays in place while the cursor moves diagonally
toward it. Set safeAreaPolygon={false} to disable this behavior, or pass an object to configure
Floating UI safePolygon options:
Flat list layout
Columns require horizontal space and do not fit narrow screens. Set withColumns={false}
to render options as a flat list of full paths instead:
Combine withColumns with the use-matches hook to render columns
on desktop and the flat list on mobile:
Max displayed levels
Use the maxDisplayedLevels prop (3 by default) to limit the number of columns displayed
next to each other. When the limit is exceeded, the first columns are hidden and a control
to reveal them is displayed on the left:
Searchable
Set the searchable prop to allow filtering options. In search mode, the columns are replaced
with a flat list of full paths that match the query:
Use the filter prop to customize how paths are matched and renderSearchOption to customize
how search results are rendered:
Controlled search value
Use searchValue and onSearchChange props to control the search value:
Nothing found
Set the nothingFoundMessage prop to display a message when no options match the search query:
Display value
By default, the selected path is displayed in the input as option labels joined by the separator
(/ by default). Use the separator prop to change the divider and the formatValue prop to
fully customize the input label:
Column width
Use the columnWidth prop to set a fixed width for every column and maxDropdownHeight
(260 by default) to set the max height of a column:
Custom option rendering
Use the renderOption prop to customize how options are rendered in columns. The function receives
the option and its column level:
Check icon
Use the withCheckIcon prop to toggle the check icon on the selected option and checkIconPosition
to change its position (left or right):
Disabled options
Set the disabled property on an option to prevent it from being selected or expanded. Disabled
options are skipped during keyboard navigation:
Left and right sections
Cascader supports leftSection and rightSection props the same way as other inputs:
Clearable
Set the clearable prop to display the clear button when a value is selected:
Use the clearSectionMode prop to control how the clear button and rightSection are rendered:
Scrollable columns
Each column is scrollable. Use scrollAreaProps to pass props down to the
ScrollArea of each column:
Control dropdown opened state
Use dropdownOpened, defaultDropdownOpened, onDropdownOpen and onDropdownClose props to
control the dropdown opened state:
Dropdown position
Use comboboxProps to pass props down to the underlying Combobox and
Popover. For example, set position to change the dropdown position:
Dropdown offset
Dropdown width
In flat list mode (withColumns={false}) the dropdown width can be controlled with
comboboxProps={{ width }}. In columns mode the dropdown is sized to the columns:
Dropdown padding
Dropdown shadow
Dropdown animation
Inside Popover
To use Cascader inside a Popover, set comboboxProps={{ withinPortal: false }}:
Combobox props
You can override Combobox props with comboboxProps. This is useful when you need to change some of the props that are not exposed by Cascader, for example withinPortal:
Change dropdown z-index
Styles API
Use the Styles API to customize Cascader styles:
Component Styles API
Hover over selectors to highlight corresponding elements
Left and right sections
Cascader supports leftSection and rightSection props. These sections are rendered with absolute positioning inside the input wrapper. You can use them to display icons, input controls, or any other elements.
You can use the following props to control sections styles and content:
rightSection/leftSection– React node to render on the corresponding side of inputrightSectionWidth/leftSectionWidth– controls the width of the right section and padding on the corresponding side of the input. By default, it is controlled by the componentsizeprop.rightSectionPointerEvents/leftSectionPointerEvents– controls thepointer-eventsproperty of the section. If you want to render a non-interactive element, set it tononeto pass clicks through to the input.
Input props
Cascader component supports Input and Input.Wrapper component features and all input element props. The Cascader documentation does not include all features supported by the component – see the Input documentation to learn about all available features.
Input description
Read only
Set readOnly to make the input read only. When readOnly is set, Cascader will not open the
dropdown and will not call the onChange function.
Disabled
Set disabled to disable the input. When disabled is set, the user cannot interact with the
input and Cascader will not open the dropdown.
Error state
Pick a valid location
Success state
Looks good!
Loading state
Set the loading prop to display a loader in the right section instead of the chevron:
Accessibility
Cascader columns are rendered as nested listboxes with option elements. To make the component
accessible, set the label prop or pass aria-label to the component: