Skip to content

Cascader

Rules

Basic Example

js
const rule = {
    type:"cascader",
    title:"Location",
    field:"address",
    value:['Shaanxi Province','Xi\'an City','Xincheng District'],
    props:{}
}

Props Configuration Examples

Searchable Cascader

js
const rule = {
    type:"cascader",
    title:"Location",
    field:"address",
    value:[],
    props:{
        options: [
            {
                value: 'beijing',
                label: 'Beijing',
                children: [
                    { value: 'chaoyang', label: 'Chaoyang District' },
                    { value: 'haidian', label: 'Haidian District' },
                ]
            },
            {
                value: 'shanghai',
                label: 'Shanghai',
                children: [
                    { value: 'huangpu', label: 'Huangpu District' },
                    { value: 'pudong', label: 'Pudong New Area' },
                ]
            }
        ],
        allowSearch: true,
        placeholder: "Select region",
        allowClear: true,
    }
}

Multiple Selection Cascader

js
const rule = {
    type:"cascader",
    title:"Product Category",
    field:"categories",
    value:[],
    props:{
        options: [
            {
                value: 'electronics',
                label: 'Electronics',
                children: [
                    { value: 'phone', label: 'Mobile Phone' },
                    { value: 'computer', label: 'Computer' },
                ]
            }
        ],
        multiple: true,
        placeholder: "Select category",
    }
}

Async Load Data

js
const rule = {
    type:"cascader",
    title:"Location",
    field:"address",
    value:[],
    props:{
        options: [
            {
                value: 'beijing',
                label: 'Beijing',
                isLeaf: false,
            }
        ],
        placeholder: "Select region",
    },
    inject: true,
    on: {
        'load-more': ($inject, option, done) => {
            // Load child data for selected parent
            loadRegionData(option.value).then(res => {
                option.children = res.data.map(item => ({
                    value: item.id,
                    label: item.name,
                    isLeaf: !item.hasChildren
                }));
                done();
            });
        },
    },
}

Events Examples

Handle Selection Changes

js
const rule = {
    type:"cascader",
    title:"Location",
    field:"address",
    value:[],
    props:{
        options: [
            {
                value: 'beijing',
                label: 'Beijing',
                children: [
                    { value: 'chaoyang', label: 'Chaoyang District' },
                ]
            }
        ],
        placeholder: "Select region",
        allowClear: true,
    },
    on: {
        change: (value, option) => {
            console.log('Selection value changed:', value, option);
        },
        clear: () => {
            console.log('Selection cleared');
        },
        search: (value) => {
            console.log('Search value:', value);
        },
    },
}

Linkage Update After Selection

js
const rule = [
    {
        type:"cascader",
        title:"Location",
        field:"address",
        value:[],
        props:{
            options: [
                {
                    value: 'beijing',
                    label: 'Beijing',
                    children: [
                        { value: 'chaoyang', label: 'Chaoyang District' },
                    ]
                }
            ],
            placeholder: "Select region",
        },
        inject: true,
        on: {
            change: ($inject, value, option) => {
                // Fill postal code by region
                if (option && option.length > 0) {
                    const postcodeMap = {
                        'chaoyang': '100020',
                        'haidian': '100080',
                    };
                    const lastOption = option[option.length - 1];
                    $inject.api.setValue('postcode', postcodeMap[lastOption.value] || '');
                }
            },
        },
    },
    {
        type:"input",
        field:"postcode",
        title:"Postal Code",
        props: {
            disabled: true,
        },
    },
]

Complete configuration items: arco-design_Cascader

value: Array

Props

ParameterDescriptionTypeDefaultVersion
path-modeWhether bound value is a pathbooleanfalse
multipleWhether in multiple selection mode (search is enabled by default in multiple mode)booleanfalse
optionsOptions for cascaderCascaderOption[][]
disabledWhether disabledbooleanfalse
errorWhether in error statebooleanfalse
sizeSize of select box'mini' | 'small' | 'medium' | 'large''medium'
allow-searchWhether to allow searchbooleanfalse (single) | true (multiple)
allow-clearWhether to allow clearbooleanfalse
popup-visible (v-model)Whether to show dropdownboolean-
expand-triggerTrigger method for expanding next levelstring'click'
default-popup-visibleWhether to show dropdown by default (uncontrolled state)booleanfalse
placeholderPlaceholderstring-
popup-containerMount container for popupstring | HTMLElement | null | undefined-
max-tag-countMaximum number of tags displayed in multiple selection mode. 0 means unlimitednumber0
format-labelFormat display content(options: CascaderOptionInfo[]) => string-
trigger-propsTrigger properties of dropdown menuTriggerProps-
check-strictlyWhether to enable strict selection modebooleanfalse
load-moreLazy load function, enables lazy loading when provided( option: CascaderOptionInfo, done: (children?: CascaderOption[]) => void) => void-2.13.0
loadingWhether in loading statebooleanfalse2.15.0

Events

Event NameDescriptionParameters
changeTriggered when selected value changesvalue: string | string[] | undefined | (string | string[])[]
input-value-changeTriggered when input value changesvalue: string
clearTriggered when clear button is clicked-
searchTriggered when user searchesvalue: string
popup-visible-changeTriggered when dropdown display state changesvisible: boolean
focusTriggered when gains focus-
blurTriggered when loses focus-

CascaderOption

ParameterDescriptionTypeDefaultVersion
valueOption value`stringnumber`-
labelOption textstring-
renderCustom renderingRenderFunction-
disabledWhether disabledbooleanfalse
tagPropsTag properties for displayTagProps-2.8.0
childrenNext level optionsCascaderOption[]-
isLeafWhether is leaf nodebooleanfalse

FormCreate is an open-source project released under the MIT License. Free for personal and commercial use.