Flutter docs
Default skin

Select

A dropdown menu for displaying choices.

When to use

  • A dropdown menu for displaying choices - an elegant alternative to the native the native select element element.
  • Utilizing Radio is recommended when there are fewer total options (less than 5).
  • You probably need AutoComplete if you're looking for an input box that can be typed or selected.

Examples

Basic Usage

Basic Usage.

Custom Search

Customize search using filterOption.

multiple selection

Multiple selection, selecting from existing items.

Custom dropdown options

Use optionRender to customize the rendering dropdown options

Tags

Allow user to select tags from list or input custom tag.

coordinate

Coordinating the selection of provinces and cities is a common use case and demonstrates how selection can be coordinated. Cascader component is strongly recommended in this case.

Automatic tokenization

Try to copy Lucy,Jack and paste to the input. Only available in tags and multiple mode.

Search and Select Users

A complete multiple select sample with remote search, debounce fetch, ajax callback order flow, and loading state.

Custom dropdown

Customize the dropdown menu via popupRender. If you want to close the dropdown after clicking the custom content, you need to control open prop, here is an codesandbox.

Variants

Variants of Select, there are four variants: outlined filled borderless and underlined.

Custom Selected Label Render

Allows custom rendering of the currently selected label, which can be used for value backfill but the corresponding option is missing and does not want to directly render the value.

Big Data

Select use virtual scroll which get better performance, turn off it by setting virtual={false}.

Placement

You can manually specify the position of the popup via placement.

Custom semantic dom styling

You can customize the semantic dom style of Select by passing objects/functions through classNames and styles.

Select with search field

Search the options while expanded.

Multi field search

Use optionFilterProp for multi-field search.

Sizes

The height of the input field for the select defaults to 32px. If size is set to large, the height will be 40px, and if set to small, 24px.

Search with sort

Search the options with sorting.

Option Group

Using OptGroup to group the options.

Get value of selected item

As a default behavior, the onChange callback can only get the value of the selected item. The labelInValue prop can be used to get the label property of the selected item. The label of the selected item will be packed as an object for passing to the onChange callback.

Custom tokenization

Customize tokenization logic to split input with your own rules.

Prefix and Suffix

Custom prefix and suffixIcon.

Hide Already Selected

Hide already selected options in the dropdown.

Custom Tag Render

Allows for custom rendering of tags.

Responsive maxTagCount

Auto collapse to tag with responsive case. Not recommend use in large form case since responsive calculation has a perf cost.

Status

Add status to Select with status, which could be error or warning.

Max Count

You can set the maxCount prop to control the max number of items can be selected. When the limit is exceeded, the options will become disabled.

Width and long options

Long options — a job, a vendor, a stock location path — used to be cut off in a field narrower than the space it had. The CeeBee Select sets three defaults on Ant's contract:

  • The field is as wide as its longest option, between 12rem and 28rem, measured from the labels in ch so the server and the client agree. It never outgrows its container, so it takes the full width on a phone. Set style={{ width }} and your width is kept.
  • The dropdown may be wider than the field, up to 32rem (popupMatchSelectWidth defaults to false), so options are read whole where there is room.
  • What still does not fit ellipsises, and the selected value and each option show their whole text in a tooltip when, and only when, they are cut. The full text stays the element's content, so the accessible name is never the shortened one. A consumer's own labelRender or optionRender replaces this for what it renders.

Clear action

When allowClear is enabled, the clear button uses the clear label from LabelsProvider; without a provider override it keeps the default “Clear” label. The Ant Design clear icon also stays intact. A caller-provided allowClear.label takes precedence over the provider label, and an explicit allowClear.clearIcon takes precedence over configured icons. Without that icon, the Select clearIcon prop, ConfigProvider's select.clearIcon, then Ant Design's default icon are used in that order.

The clear action has a token-sized hit area around its compact icon. It remains visible when reached by keyboard focus, with the shared focus indicator, even while the pointer is outside the Select.

Wrap the part of the app that needs localized library labels with LabelsProvider:

tsx
import { LabelsProvider, Select } from '@ceebee/ui/client';
<LabelsProvider labels={{ clear: 'Clear choice' }}>  <Select allowClear options={[{ value: 'a', label: 'First choice' }]} value="a" /></LabelsProvider>

An explicit label and icon stay with the Select:

tsx
<Select  allowClear={{ label: 'Remove choice', clearIcon: <span aria-hidden="true">×</span> }}  options={[{ value: 'a', label: 'First choice' }]}  value="a"/>

allowClear={false} disables clearing even when a ConfigProvider enables it. Omitting allowClear keeps Ant Design's configured behavior, including a provider-level select.allowClear setting.

Sizes

small, middle (the default), and large map to --cb-control-height-sm, --cb-control-height-md, and --cb-control-height-lg. Each is max() of a preferred step (--cb-control-height-base-*) and the active pointer floor, so a density scale can retune the ladder but never take a control under its floor. On a coarse pointer — a touch screen — --cb-control-floor becomes --cb-control-floor-coarse (2.75rem, 44px), so small and middle both reach 44px and large keeps its 48px, with no per-control CSS. A pointer that hovers keeps --cb-control-floor-fine (2rem, 32px).

API

Select, Select.Option, and Select.OptGroup are exported from @ceebee/ui/client.

Select props

PropertyDescriptionTypeDefaultVersion
allowClearCustomize clear iconboolean | { clearIcon?: ReactNode }false5.8.0: Support object type
autoClearSearchValueWhether the current search will be cleared on selecting an item. Only applies when mode is set to multiple or tagsbooleantrue—
borderedWhether has border style, please use variant insteadbooleantrue-
classNamesCustomize class for each semantic structure inside the Select component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-—
defaultActiveFirstOptionWhether active first option by defaultbooleantrue—
defaultOpenInitial open state of dropdownboolean-—
defaultValueInitial selected optionstring | string\[] | <br />number | number\[] | <br />LabeledValue | LabeledValue\[]-—
disabledWhether disabled selectbooleanfalse—
dropdownClassNameThe className of dropdown menu, please use classNames.popup.root insteadstring--
dropdownMatchSelectWidthDetermine whether the popup menu and the select input are the same width, please use popupMatchSelectWidth insteadboolean | numbertrue-
popupClassNameThe className of dropdown menu, use classNames.popup.root insteadstring-4.23.0
popupMatchSelectWidthDetermine whether the popup menu and the select input are the same width. Default set min-width same as input. Will ignore when value less than select width. false will disable virtual scrollboolean | numbertrue5.5.0
dropdownRenderCustomize dropdown content, use popupRender instead(originNode: ReactNode) => ReactNode-—
popupRenderCustomize dropdown content(originNode: ReactNode) => ReactNode-5.25.0
dropdownStyleThe style of dropdown menu, use styles.popup.root insteadCSSProperties-—
fieldNamesCustomize node label, value, options, groupLabel field nameobject{ label: label, value: value, options: options, groupLabel: label }4.17.0 (groupLabel added in 5.6.0)
filterOptionIf true, filter options by input, if function, filter options against it. 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 excludedboolean | function(inputValue, option)true—
filterSortSort function for search options sorting, see Array.sort's compareFunction(optionA: Option, optionB: Option, info: { searchValue: string }) => number-searchValue: 5.19.0
getPopupContainerParent 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. Examplefunction(triggerNode)() => document.body—
labelInValueWhether to embed label in value, turn the format of value from string to { value: string, label: ReactNode }booleanfalse—
listHeightConfig popup heightnumber256—
loadingIndicate loading statebooleanfalse—
loadingIconCustomize the loading iconReactNode<LoadingOutlined spin />6.4.0
maxCountThe max number of items can be selected, only applies when mode is multiple or tagsnumber-5.13.0
maxTagCountMax tag count to show. responsive will cost render performancenumber | responsive-responsive: 4.10
maxTagPlaceholderPlaceholder for not showing tagsReactNode | function(omittedValues)-—
maxTagTextLengthMax tag text length to shownumber-—
menuItemSelectedIconThe custom menuItemSelected icon with multiple optionsReactNode<CheckOutlined />—
modeSet mode of Selectmultiple | tags-—
notFoundContentSpecify content to show when no result matchesReactNodeNot Found—
openControlled open state of dropdownboolean-—
optionFilterPropDeprecated, see showSearch.optionFilterProp———
optionLabelPropWhich prop value of option will render as content of select. Examplestringchildren—
optionsSelect options. Will get better perf than jsx definition{ label, value }\[]-—
optionRenderCustomize the rendering dropdown options(option: FlattenOptionData\<BaseOptionType\> , info: { index: number }) => React.ReactNode-5.11.0
placeholderPlaceholder of selectReactNode-—
placementThe position where the selection box pops upbottomLeft bottomRight topLeft topRightbottomLeft—
prefixThe custom prefixReactNode-5.22.0
removeIconThe custom remove iconReactNode<CloseOutlined />—
searchValueThe current input "search" textstring-—
showArrowWhether to show the arrow icon, please use suffixIcon={null} insteadbooleantrue-
showSearchWhether select is searchableboolean | Objectsingle: false, multiple: trueObject: 6.0.0
sizeSize of Select inputlarge | medium | smallmedium—
statusSet validation status'error' | 'warning'-4.19.0
stylesCustomize inline style for each semantic structure inside the Select component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-—
suffixIconThe custom suffix icon. Custom icons will not respond to clicks to open, because the replaced icon may be designed for other interactions. You can use pointer-events: none style to bypassReactNode<DownOutlined />—
tagRenderCustomize tag render, only applies when mode is set to multiple or tags(props) => ReactNode-—
labelRenderCustomize selected label render (LabelInValueType definition see LabelInValueType)(props: LabelInValueType) => ReactNode-5.15.0
tokenSeparatorsSeparator used to tokenize, only applies when mode="tags" or mode="multiple"string[] | ((input: string) => string[])-function: 6.5.0
valueCurrent selected option (considered as a immutable array)string | string\[] | <br />number | number\[] | <br />LabeledValue | LabeledValue\[]-—
variantVariants of selectoroutlined | borderless | filled | underlinedoutlined5.13.0 | underlined: 5.24.0
virtualDisable virtual scroll when set to falsebooleantrue4.1.0
onActiveCalled when keyboard or mouse interaction occursfunction(value: string | number | LabeledValue)-—
onBlurCalled when blurfunction-—
onChangeCalled when select an option or input value changefunction(value, option:Option | Array&lt;Option>)-—
onClearCalled when clearfunction-4.6.0
onDeselectCalled when an option is deselected, param is the selected option's value. Only called for multiple or tags, effective in multiple or tags mode onlyfunction(value: string | number | LabeledValue)-—
onDropdownVisibleChangeCalled when dropdown open, use onOpenChange instead(open: boolean) => void-—
onOpenChangeCalled when dropdown open(open: boolean) => void-—
onFocusCalled when focus(event: FocusEvent) => void-—
onInputKeyDownCalled when key pressed(event: KeyboardEvent) => void-—
onPopupScrollCalled when dropdown scrolls(event: UIEvent) => void-—
onSearchCallback function that is fired when input changedfunction(value: string)-—
onSelectCalled when an option is selected, the params are option's value (or key) and option instancefunction(value: string | number | LabeledValue, option: Option)-—

showSearch

PropertyDescriptionTypeDefaultVersion
autoClearSearchValueWhether the current search will be cleared on selecting an item. Only applies when mode is set to multiple or tagsbooleantrue—
filterOptionIf true, filter options by input, if function, filter options against it. 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 excludedboolean | function(inputValue, option)true—
filterSortSort function for search options sorting, see Array.sort's compareFunction(optionA: Option, optionB: Option, info: { searchValue: string }) => number-searchValue: 5.19.0
optionFilterPropWhich prop value of option will be used for filter if filterOption is true. <br/> If options is set, it should be set to label. <br/> When a string[] is provided, multiple fields are searched using OR matching.string | string[]valuestring[]: 6.1.0
searchValueThe current input "search" textstring-—
onSearchCallback function that is fired when input changedfunction(value: string)-—
searchIconCustomize the search iconReactNode<SearchOutlined />6.4.0

Option props

PropertyDescriptionTypeDefaultVersion
classNameThe additional class to optionstring-—
disabledDisable this optionbooleanfalse—
titletitle attribute of Select Optionstring-—
valueDefault to filter with this propertystring | number-—

OptGroup props

PropertyDescriptionTypeDefaultVersion
keyGroup keystring-—
labelGroup labelReact.ReactNode-—
classNameThe additional class to optionstring-—
titletitle attribute of Select Optionstring-—