Cascader
Cascade selection box.
When To Use
- When you need to select from a set of associated data set. Such as province/city/district, company level, things classification.
- When selecting from a large data set, with multi-stage classifications separated for easy selection.
- Chooses cascade items in one float layer for better user experience.
Examples
- Basic ·
basic - Default value ·
default-value - Custom trigger ·
custom-trigger - Hover ·
hover - Disabled option ·
disabled-option - Change on select ·
change-on-select - Multiple ·
multiple - ShowCheckedStrategy ·
showCheckedStrategy - Size ·
size - Custom render ·
custom-render - Search ·
search - Load Options Lazily ·
lazy - Custom Field Names ·
fields-name - Prefix and Suffix ·
suffix - Custom dropdown ·
custom-dropdown - Placement ·
placement - Variants ·
variant - Status ·
status - Custom semantic dom styling ·
style-class - Panel ·
panel
API
Common props ref:Common props
<Cascader options={options} onChange={onChange} />
| Property | Description | Type | Default | Version | Global Config |
|---|---|---|---|---|---|
| allowClear | Show clear button | boolean | { clearIcon?: ReactNode } | true | 5.8.0: Support object type | clearIcon: 6.4.0 |
Whether the current search will be cleared on selecting an item. Only applies when multiple is true | boolean | true | 5.9.0 | × | |
Whether has border style, please use variant instead | boolean | true | - | × | |
| changeOnSelect | Change value on each selection if set to true, see above demo for details | boolean | false | × | |
| classNames | Customize class for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string> | - | 5.25.0 | |
| defaultOpen | Initial visible of cascader popup | boolean | - | × | |
| defaultValue | Initial selected value | string[] | number[] | [] | × | |
| disabled | Whether disabled select | boolean | false | × | |
| displayRender | The render function of displaying selected options | (label, selectedOptions) => ReactNode | label => label.join(/) | multiple: 4.18.0 | × |
| tagRender | Custom render function for tags in multiple mode | (label: string, onClose: function, value: string) => ReactNode | - | × | |
The additional className of popup overlay, use classNames.popup.root instead | string | - | 4.23.0 | × | |
The additional className of popup overlay, please use classNames.popup.root instead | string | - | - | × | |
Customize dropdown content, use popupRender instead | (menus: ReactElement) => ReactNode | - | 4.4.0 | × | |
| popupRender | Customize dropdown content | (menus: ReactElement) => ReactNode | - | × | |
The style of dropdown menu, use styles.popup.root instead | CSSProperties | - | × | ||
| expandIcon | Customize the current item expand icon | ReactNode | - | 4.4.0 | 6.3.0 |
| expandTrigger | expand current item when click or hover, one of click hover | string | click | × | |
| fieldNames | Custom field name for label and value and children | object | { label: label, value: value, children: children } | × | |
| getPopupContainer | Parent Node which the selector should be rendered to. Default to body. When position issues happen, try to modify it into scrollable content and position it relative. example | function(triggerNode) | () => document.body | × | |
| loadData | To load option lazily, and it cannot work with showSearch | (selectedOptions) => void | - | × | |
| loadingIcon | Customize the loading icon | ReactNode | - | 6.3.0 | |
| maxTagCount | Max tag count to show. responsive will cost render performance | number | responsive | - | 4.17.0 | × |
| maxTagPlaceholder | Placeholder for not showing tags | ReactNode | function(omittedValues) | - | 4.17.0 | × |
| maxTagTextLength | Max tag text length to show | number | - | 4.17.0 | × |
| notFoundContent | Specify content to show when no result matches | ReactNode | No data | × | |
| open | Set visible of cascader popup | boolean | - | 4.17.0 | × |
| options | The data options of cascade | Option[] | - | × | |
| placeholder | The input placeholder | string | - | × | |
| placement | Use preset popup align config from builtinPlacements | bottomLeft bottomRight topLeft topRight | bottomLeft | 4.17.0 | × |
| prefix | The custom prefix | ReactNode | - | 5.22.0 | × |
Whether to show the arrow icon, please use suffixIcon={null} instead | boolean | true | - | × | |
| showSearch | Whether show search input in single mode | boolean | Object | false | searchIcon: 6.4.0 | |
| size | The input size | large | medium | small | medium | × | |
| status | Set validation status | 'error' | 'warning' | - | 4.19.0 | × |
| styles | Customize inline style for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties> | - | 5.25.0 | |
| suffixIcon | The custom suffix icon | ReactNode | - | 6.4.0 | |
| value | The selected value | string[] | number[] | - | × | |
| variant | Variants of selector | outlined | borderless | filled | underlined | outlined | 5.13.0 | underlined: 5.24.0 | 5.19.0 |
| onChange | Callback when finishing cascader select | (value, selectedOptions) => void | - | × | |
| onClear | Called when clear | () => void | - | - | × |
Callback when popup shown or hidden, use onOpenChange instead | (value) => void | - | 4.17.0 | × | |
| onOpenChange | Callback when popup shown or hidden | (open: boolean) => void | - | × | |
Callback when popup shown or hidden, please use onOpenChange instead | (value) => void | - | - | × | |
| multiple | Support multiple or not | boolean | - | 4.17.0 | × |
| removeIcon | The custom remove icon | ReactNode | - | 6.4.0 | |
| showCheckedStrategy | The way to show selected items in the box (only effective when multiple is true). Cascader.SHOW_CHILD: just show child treeNode. Cascader.SHOW_PARENT: just show parent treeNode (when all child treeNode under the parent treeNode are checked) | Cascader.SHOW_PARENT | Cascader.SHOW_CHILD | Cascader.SHOW_PARENT | 4.20.0 | × |
Set search value, Need work with showSearch | string | - | 4.17.0 | × | |
| The callback function triggered when input changed | (search: string) => void | - | 4.17.0 | × | |
The style of the drop-down menu column, use styles.popup.listItem instead | CSSProperties | - | × | ||
The style of the drop-down menu column, use styles.popup.listItem instead | CSSProperties | - | × | ||
| optionRender | Customize the rendering dropdown options | (option: Option) => React.ReactNode | - | 5.16.0 | × |
showSearch
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| autoClearSearchValue | Whether the current search will be cleared on selecting an item. Only applies when multiple is true | boolean | true | 5.9.0 |
| filter | The function will receive two arguments, inputValue and option, if the function returns true, the option will be included in the filtered set; Otherwise, it will be excluded | function(inputValue, path): boolean | - | |
| limit | Set the count of filtered items | number | false | 50 | |
| matchInputWidth | Whether the width of list matches input, (how it looks) | boolean | true | |
| render | Used to render filtered options | function(inputValue, path): ReactNode | - | |
| sort | Used to sort filtered options | function(a, b, inputValue) | - | |
| searchValue | Set search value, Need work with showSearch | string | - | 4.17.0 |
| onSearch | The callback function triggered when input changed | (search: string) => void | - | 4.17.0 |
| searchIcon | Customize the search icon | ReactNode | - | 6.3.0 |
Option
interface Option {
value: string | number;
label?: React.ReactNode;
disabled?: boolean;
children?: Option[];
// Determines if this is a leaf node(effective when `loadData` is specified).
// `false` will force trade TreeNode as a parent node.
// Show expand icon even if the current node has no children.
isLeaf?: boolean;
}
Methods
| Name | Description | Version |
|---|---|---|
| blur() | Remove focus | |
| focus() | Get focus |
Semantic DOM
| Semantic node | Native description | Version |
|---|---|---|
root | Root element with relative positioning, inline-flex layout, cursor styles, transitions, border and other basic selector container styles | — |
prefix | Prefix element with layout and styling for prefix content | — |
content | Multiple selection container with layout, spacing, and wrapping styles for selected items | — |
placeholder | Placeholder element with font styles and colors for placeholder text | — |
clear | Clear button element with layout, styling and interactive effects for clear button | — |
input | Input element with search input styling, cursor control, font inheritance and other search-related styles. Remove border styles | — |
suffix | Suffix element with layout and styling for suffix content like clear button, arrow icon, etc. | — |
popup.root | Popup element with popup layer positioning, z-index, background, border, box-shadow and other popup container styles | — |
popup.list | Popup list element with option list layout, scrolling, max-height and other list container styles | — |
popup.listItem | Popup item element with option item padding, hover effects, selected states, disabled states and other option interactive styles | — |
item | Multiple selection item element with border, background, padding, and margin styles (multiple) | — |
itemContent | Multiple selection item content area with text ellipsis styles (multiple) | — |
itemRemove | Multiple selection item remove button with font-related styles (multiple) | — |
Semantic description source: vendor/.dumi/theme/common/SelectSemanticTemplate.tsx
Design Token
Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.
| Token | Type | Native description |
|---|---|---|
controlWidth | number | string | Width of Cascader |
controlItemWidth | number | string | Width of item |
dropdownHeight | number | string | Height of dropdown |
optionSelectedBg | string | Background color of selected item |
optionSelectedColor | string | Text color when option is selected |
optionSelectedFontWeight | CSSProperties['fontWeight'] | Font weight of selected item |
optionPadding | CSSProperties['padding'] | Padding of menu item |
menuPadding | CSSProperties['padding'] | Padding of menu item (single column) |
Declaration source: vendor/components/cascader/style/index.ts
import type { CSSProperties } from 'react';
import { genCompactItemStyle } from '../../style/compact-item';
import type { FullToken, GenerateStyle, GlobalToken } from '../../theme/internal';
import { genStyleHooks } from '../../theme/internal';
import getColumnsStyle from './columns';
export interface ComponentToken {
/**
* @desc 选择器宽度
* @descEN Width of Cascader
*/
controlWidth: number | string;
/**
* @desc 选项宽度
* @descEN Width of item
*/
controlItemWidth: number | string;
/**
* @desc 下拉菜单高度
* @descEN Height of dropdown
*/
dropdownHeight: number | string;
/**
* @desc 选项选中时背景色
* @descEN Background color of selected item
*/
optionSelectedBg: string;
/**
* @desc 选项选中时文本颜色
* @descEN Text color when option is selected
*/
optionSelectedColor: string;
/**
* @desc 选项选中时字重
* @descEN Font weight of selected item
*/
optionSelectedFontWeight: CSSProperties['fontWeight'];
/**
* @desc 选项内间距
* @descEN Padding of menu item
*/
optionPadding: CSSProperties['padding'];
/**
* @desc 选项菜单(单列)内间距
* @descEN Padding of menu item (single column)
*/
menuPadding: CSSProperties['padding'];
}
export type CascaderToken = FullToken<'Cascader'>;
Shared native props
Tips: The following generic properties apply to most antd components; those not supported are described separately.
| Property | Description | Type | Default |
|---|---|---|---|
| style | The additional style | CSSProperties | - |
| className | The additional css class | string | - |
| rootClassName | ClassName on the root element | string | - |
| autoFocus | Auto focus when component mounted, only effective for focusable elements like forms, links, etc. | boolean | false |
Install and reproduce an example
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23
Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.
Native type references
The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.
vendor/components/cascader/Panel.tsxvendor/components/cascader/hooks/useIcons.tsxvendor/components/cascader/index.tsxvendor/components/cascader/style/index.ts
Source and license
https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd
Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.