Skip to content

Select

Rules

Basic Example

js
const rule = {
    type: "select",
    field: "cate_id",
    title: "Product Category",
    value: ["104","105"],
    options: [
        {"value": "104", "label": "Organic Vegetables", "disabled": false},
        {"value": "105", "label": "Fresh Fruits", "disabled": false},
     ],
    props: {
        multiple: true
    },
}

Props Configuration Examples

Single Select Dropdown

js
const rule = {
    type: "select",
    field: "category",
    title: "Product Category",
    value: "104",
    options: [
        {"value": "104", "label": "Organic Vegetables"},
        {"value": "105", "label": "Fresh Fruits"},
        {"value": "106", "label": "Seafood"},
    ],
    props: {
        placeholder: "Select product category",
        allowClear: true,
    },
}

Multiple Select Dropdown

js
const rule = {
    type: "select",
    field: "tags",
    title: "Product Tags",
    value: ["104","105"],
    options: [
        {"value": "104", "label": "Hot Sale"},
        {"value": "105", "label": "New Product"},
        {"value": "106", "label": "Recommended"},
    ],
    props: {
        multiple: true,
        maxTagCount: 2,
        placeholder: "Select tags",
    },
}

Searchable Dropdown

js
const rule = {
    type: "select",
    field: "product",
    title: "Product Name",
    options: [
        {"value": "1", "label": "iPhone 15 Pro"},
        {"value": "2", "label": "MacBook Pro"},
        {"value": "3", "label": "iPad Air"},
    ],
    props: {
        allowSearch: true,
        placeholder: "Enter or select product",
        allowClear: true,
    },
}
js
const rule = {
    type: "select",
    field: "user",
    title: "Select User",
    options: [],
    props: {
        allowSearch: true,
        placeholder: "Enter username to search",
        allowClear: true,
        loading: false,
    },
    inject: true,
    on: {
        search: ($inject, value) => {
            if (value) {
                // Call remote search API
                searchUsers(value).then(res => {
                    // Update options
                    $inject.api.updateRule('user', {
                        options: res.data.map(item => ({
                            value: item.id,
                            label: item.name
                        }))
                    });
                });
            }
        },
    },
}

Events Examples

Handle Selection Changes

js
const rule = {
    type: "select",
    field: "category",
    title: "Product Category",
    options: [
        {"value": "104", "label": "Organic Vegetables"},
        {"value": "105", "label": "Fresh Fruits"},
    ],
    props: {
        placeholder: "Select category",
        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 Other Fields After Selection

js
const rule = [
    {
        type: "select",
        field: "category",
        title: "Product Category",
        options: [
            {"value": "1", "label": "Electronics"},
            {"value": "2", "label": "Clothing & Accessories"},
        ],
        props: {
            placeholder: "Select category",
        },
        inject: true,
        on: {
            change: ($inject, value) => {
                // Load subcategories based on selection
                if (value === "1") {
                    $inject.api.updateRule('subcategory', {
                        options: [
                            {"value": "11", "label": "Mobile Phones"},
                            {"value": "12", "label": "Computers"},
                        ]
                    });
                } else if (value === "2") {
                    $inject.api.updateRule('subcategory', {
                        options: [
                            {"value": "21", "label": "Men's Clothing"},
                            {"value": "22", "label": "Women's Clothing"},
                        ]
                    });
                }
            },
        },
    },
    {
        type: "select",
        field: "subcategory",
        title: "Subcategory",
        options: [],
        props: {
            placeholder: "Select category first",
            disabled: true,
        },
    },
]

Complete configuration items: arco-design_Select

value: Number | String | Array

Options

ParameterDescriptionTypeDefault
valueOption valueOptionValue-
labelOption contentstring-
disabledWhether disabledbooleanfalse
tagPropsProperties of multi-select tag for optionany-
renderCustom renderingRenderFunction-

Props

ParameterDescriptionTypeDefaultVersion
multipleWhether to enable multiple selection mode (search is enabled by default in multiple mode)booleanfalse
sizeSize of select box'mini' | 'small' | 'medium' | 'large''medium'
placeholderPlaceholderstring-
loadingWhether in loading statebooleanfalse
disabledWhether disabledbooleanfalse
errorWhether in error statebooleanfalse
allow-clearWhether to allow clearbooleanfalse
allow-searchWhether to allow searchboolean | { retainInputValue?: boolean }`false (single)true (multiple)`
allow-createWhether to allow createbooleanfalse
max-tag-countMaximum number of tags displayed in multiple selection mode. 0 means unlimitednumber0
popup-containerMount container for popupstring | HTMLElement-
borderedWhether to show input box borderbooleantrue
popup-visibleWhether to show dropdown menuboolean-
default-popup-visibleWhether popup is visible by default (uncontrolled mode)booleanfalse
unmount-on-closeWhether to destroy elements when dropdown menu closesbooleanfalse
filter-optionWhether to filter optionsboolean | ((inputValue: string, optionInfo: OptionInfo) => boolean)true
optionsOption dataOption[][]
virtual-list-propsPass virtual list properties, pass this parameter to enable virtual scrolling VirtualListPropsVirtualListProps-
trigger-propsTrigger properties of dropdown menuTriggerProps-
format-labelFormat display content(data: OptionInfo) => string-
fallback-optionCustom option for values that don't existboolean| ((value: string | number | Record<string, unknown>) => OptionData) | false2.10.0
show-extra-optionsWhether to show extra options in dropdown menubooleantrue2.10.0
value-keyProperty name used to determine option key valuestring'value'2.18.0

Events

Event NameDescriptionParameters
changeTriggered when value changes-
input-value-changeTriggered when input box value changes-
popup-visible-changeTriggered when dropdown display state changes-
clearTriggered when clear button is clicked-
removeTriggered when tag delete button is clicked-
searchTriggered when user searches-
dropdown-scrollTriggered when dropdown menu scrolls-
dropdown-reach-bottomTriggered when dropdown menu scrolls to bottom-

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