Ant Design Svelte

Select

Select from a list with search and multiple selection.

When to use

Select allows you to select a ready-made value from the list, and in tags mode - create a string tag. Use it when there are a lot of options or it is more convenient to search for them by signature rather than constantly display them on the page.

For a few short options, consider Radio. If the user must enter free text with hints, AutoComplete is needed. TreeSelect and Cascader are intended for selection from the hierarchy.

In @woodger/antd, a single Select stores a string or number, mode="multiple" stores an array of values ​​of the same type. The mode="tags" mode additionally creates strings; the number 0 and the string "0" remain different values. options is optional and defaults to an empty array.

Select CSS prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. Control, tags and popup follow prefixCls. Service variables share a common namespace regardless of local class and theme. The open list, search input and selection are saved.

Meaning, signature and clearing

By default, each variant in options contains a unique value and a text label. The value is used in the application model, the signature is used for display to the user. The number 0, the number 1, and the string "1" retain their types: test for absence of a choice via undefined, not via the truth value.

Script State Working example
One option String or number Basic selection
Multiple options An array, mode="multiple" Multiple selection
Get the label An object with value and label when labelInValue is enabled Value and label
Link two lists Update options and the dependent value Coordinated lists

For local reactive state use bind:value. If the state belongs to model Form, pass value and update the model via onValueChange. The initial uncontrolled value is set via defaultValue; subsequent changes to this property do not reinitialize the field.

allowClear adds cleaning. A single field returns undefined, a multiple field returns []. Store this format in the handler. In native FormData the values ​​become strings; this does not change the reactive model types.

multiple selects existing options, while tags allows free input. labelInValue keeps the label with the value; see selected labels. Current coverage and remaining limitations are listed in example coverage.

Tags and restrictions

Tags confirms the new option via Enter, selection in the list or blur. blur trims white space around the edges; Escape saves unfinished input. Clearing also removes pending search. By default, tags searches by value; for the label, set showSearch.optionFilterProp="label". autoClearSearchValue=false preserves local search when selected; the managed row is updated by the owner.

Separators work in multiple/tags. The tokenSeparators array terminates parts of the input; multiple accepts ready-made options, tags creates strings. The function receives the entire string and can normalize whitespace. IME is not parsed in the middle of composition. The native handler can override paste/composition; Additional input interception in the application is usually not needed.

maxCount limits the new selected values. It doesn't trim defaultValue or the owner array. maxTagCount limits only visible tags; the values ​​are saved in the model, FormData and reset. Numerical limit shows maxTagPlaceholder with hidden full label. responsive measures the width in the browser; With SSR, all values ​​are visible before measurement.

maxTagTextLength changes only the text and adds "..."; the full label/title and value are preserved. The length is calculated in UTF-16, without a surrogate pair break, but not according to grapheme clusters. tagRender gets label as Snippet, value/index and onClose for regular tag. The summary tag has isMaxTag=true without value/index/onClose. The close's own control should control mousedown so as not to open the popup as a side event.

optionRender customizes passive option content. SelectFlattenOption<value, optionType>.data contains the source record, while label has type unknown. The index includes group headings; groupOption=true identifies a grouped option. The renderer runs for options, not headings. Select retains selection, the selected label, and the native option button. Keep interactive controls out of the option button.

Opening list

popupMatchSelectWidth sets the popup width: true matches the control width, false fits its content, and a number sets the width in px. The control width remains the minimum, so a smaller number does not narrow the popup. Select popup width compares these options. An omitted prop or undefined inherits ConfigProvider.popupMatchSelectWidth; without a shared setting, true is used.

Changing width preserves the field and selected value. After the first opening, an invalid numeric CSS width retains the last accepted value, including across closing and reopening. The inner viewport is capped at 256 px by default; popup padding and borders are added outside it. Windowing and scrolling are described under long lists.

placement selects the preferred popup corner: bottomLeft, bottomRight, topLeft or topRight. The default is bottomLeft, or bottomRight in RTL. Select popup placement switches between all four options without resetting the selection. The popup may flip when space is limited.

ConfigProvider.popupOverflow sets the overflow calculation region: the viewport or the document region. The shared example demonstrates inheritance and an explicit reset. The popup uses a fixed native popover above the page even without getPopupContainer; the DOM parent and field state are retained.

open controls visibility, including through bind:open. onOpenChange reports the request: the owner can accept or reject it. Opening control shows both methods. The initial or outer change to open itself does not trigger a callback or change focus to the field.

defaultOpen specifies only the initial state and is inferior to open. Initial opening is used after mount: with SSR aria-expanded=false, popup is not created, optionRender/getter are not called. Subsequent changes to defaultOpen do not re-open the list. Removing a managed open returns a closed unmanaged state.

disabled hides popup without callback. The unmanaged list remains closed after re-enable; passed by the owner open=true saves the request and shows the list again. The outer closure of single clears the inner search, but the managed searchValue changes the owner. The values ​​and DOM fields are preserved.

When the output is empty, local notFoundContent=null, false or an empty string hides the popup, preserving raw open and input. The number 0 remains visible. General RenderEmptyContent supported, including boolean and readonly arrays; after options appears, the list becomes visible. In the form reset closes bind:open; the explicitly transferred open remains with the owner.

Long lists and scrolling

For a large option set, Select renders a visible window and measures row heights. The 100000-option example preserves multiple selection and lets you jump to the end through the public ref.

listHeight sets the inner viewport height; 0 removes the limit. Popup padding and borders are added outside it. listItemHeight estimates a row's height before measurement and defaults to token.controlHeight; 0 disables windowing.

To render the complete option DOM, set virtual={false}. Without a local prop, ConfigProvider.virtual applies. An explicitly supplied virtual={undefined} enables default=true, including under provider=false. popupMatchSelectWidth=false also disables virtualization; numeric 0 preserves it.

bind:this provides SelectRef: focus and blur control the editor focus, while scrollTo(50000) scrolls to an index, including rows outside the current window. Indices include group headings. Set key on the source record for scrolling by key: without it, the literal value is used, then an automatic key. Mapping fieldNames.value does not change this rule. scrollTo({ top: 0 }) sets a position in px. An index/key request runs after opening the list and updating the DOM with tick, as shown in the example.

onActive reports the active value or null separately from the selected model. On scrolling, onPopupScroll receives the native event from the inner viewport; currentTarget and this refer to that div.

Groups and source records

To organize options into categories, pass one level of groups, as shown in the group example. Headings cannot be selected; keyboard navigation skips them and disabled options. Matching a group name can retain all its children.

When application records use other field names, fieldNames maps value, label, options, and groupLabel to those fields. Source record fields demonstrates numeric codes, labels, and groups without first converting them into value/label. The third parameter of SelectProps<Value, Mode, OptionType> specifies the record type; the selected model remains a string, number, or array of these values. Empty names use the standard fields, and groupLabel defaults to the resolved label field.

onChange reports changes to selected values and provides a shallow copy of a record or an array of copies. Additional fields are preserved. Callbacks do not add value/label fields when the source record does not contain them. onSelect runs for every selection, including repeated single selection; onDeselect runs when an individual value is removed in multiple/tags. onClear runs before onChange during a full clear; clearing does not produce onDeselect. bind:value and onValueChange continue to connect the model.

A displayed selected record stays cached after leaving the current results until it is deselected. This lets an application hide selected options while retaining their labels and callback data. For a duplicate value, Select uses the last record in the current data map.

For a free tag with no source record, onSelect and onDeselect receive {} and onChange receives that object in its array of records. The types in tags mode account for this case. Check that a field is defined before using it.

The fruit example removes a selected record from options immediately. Its tag keeps the label. Removing the tag passes the original record, including its SKU, to onDeselect.

title, className, style, and supported DOM/data-/aria-* attributes on source options reach the list elements. style accepts a CSS object or a native CSS string; group headings use className, title, and their label. The group example emphasizes Svelte through fontWeight and includes a custom data attribute.

filterOption receives a copy of the source option or group. filterSort sorts groups and their standard options field; when fieldNames renames the children field, the application prepares the order within those groups.

Selected labels

labelInValue changes the model to { value, label }, or an array of these objects in multiple/tags mode. An explicit owner label takes priority; undefined is read from optionLabelProp or the label field specified in fieldNames. A top-level null clears selection. For an explicit specialization, use Select<Value, Mode, OptionType, true> and SelectLabelValue<Value>; the first three parameters retain their meaning.

Rich labels uses actual Svelte snippets in options. optionLabelProp selects a separate field for the selected label; configure filtering on that field independently through showSearch.optionFilterProp. Rich content is not converted to editor text.

labelRender receives label, value, key, disabled and title and returns text, an array of content or a Snippet. key equals the raw value. The function also runs during SSR and must remain pure. null/undefined falls back to the raw value; false and an empty string keep the label empty. In the example, a missing record retains its numeric ID in the model and FormData.

onChange passes labels from the current conversion; onSelect/onDeselect uses the raw record’s fieldNames.label, independently of optionLabelProp and labelRender. Removing a tag may pass the remaining labels produced by labelRender through onChange. FormData always contains raw values. A label may be a Snippet or other content; check its type before using it as a string.

Custom popup and styling

The extra action uses popupRender: a pure function receives the original menu Snippet and returns content. A Snippet with an origin argument can render the menu and add adjacent elements. The button’s mousedown handler preserves editor focus; interactive elements stay outside option buttons.

popupRender also runs while closed, including during SSR. Its content mounts after the first opening and retains state after closing; a new renderer supplied while closed is accepted on reopening. null/undefined/false or an empty string leaves the popup empty. Without the original menu, arrows and Enter do not select options, and Escape does not close this popup; blur and outside clicks retain their usual behavior. A custom popup isolates FormItem status/feedback and Compact while retaining Form disabled/variant.

Semantic styles use classNames/styles as objects or pure functions receiving props. Slots include root, prefix, suffix, input, placeholder, content, item, itemContent, itemRemove, clear and popup.root/list/listItem. prefix accepts content before the editor; a falsy scalar, including 0, creates no node. rootClassName applies to the control and popup. An object in style styles the control; the existing class and CSS-string style remain on the outer container.

ConfigProvider.select provides variant, class/style, classNames/styles, showSearch, icons and a boolean or object allowClear. Local values take priority; an explicitly supplied select in a nested provider replaces the parent record. Classes combine, control styles apply in layers, and a local popup leaf replaces the matching provider leaf entirely. For example, a local popup.root does not inherit individual CSS properties from the shared popup.root.

Icons and accessible clearing

The icon example combines shared ConfigProvider.select settings with a local suffix. loadingIcon sets the loading glyph, showSearch.searchIcon the glyph of an open searchable field, menuItemSelectedIcon the option mark, and removeIcon the removal glyph for a standard tag. Local settings take priority.

suffix replaces the entire trailing area, including Form feedback. Its function receives SelectSuffixInfo: searchValue, open, focused, showSearch and loading. null/undefined restore the standard suffix. Functions passed to suffix, menuItemSelectedIcon and removeIcon must be pure: they also run during SSR and while the list is closed. Return a snippet from a function or wrap it in an array to use it as content; loadingIcon, searchIcon and clearIcon accept snippets directly.

allowClear accepts a boolean or an object with clearIcon and label. Provide a translated accessible label in the object; otherwise it uses “clear”. boolean true keeps the standard localized label. The disabled and tabIndex fields documented by the current Ant Design release are not available yet.

Custom editor and field

The tag editor uses components.input inside the standard field. Selection, multiple/tags, responsive overflow and tagRender remain available. The snippet receives SelectInputContext: forward attributes to the editor and connect register with a Svelte attachment. Registration is released when the element is removed. bind:this exposes focus and blur for the registered editor.

The field replacement uses components.root and SelectRootContext. Root replaces the whole field: the standard editor, tags, prefix, suffix and clear button are not rendered, and components.input is ignored. The application supplies its field’s content and styling. Typing into root does not update Select’s search or value automatically.

The editor’s own props override generated attributes; root uses the opposite priority. Only pass settings you intend to override. rootElement and EditorElement describe the registered element types; bind:nativeElement and bind:inputElement return the corresponding elements after mount. The extended replacement API is partially ported; these examples demonstrate supported scenarios rather than full React compatibility.

Examples

lucy

Main choice

Single selection, disabled, loading and allowClear. The value is associated with the model via bind:value.

Search by multiple fields

showSearch.optionFilterProp searches for source options by label and email.

["a","c"]

Multiple choice

mode="multiple" binds an array of ready-made values. Selected items can be deleted or cleared entirely.

Three sizes

large, medium and small. Without local size, ConfigProvider.componentSize is valid.

Search with sorting

showSearch.filterSort sorts the result: first the match at the beginning of the name, then the alphabet.

svelte Selections: 0

Option groups

Groups, label search, a disabled option, and repeated onSelect events.

[0] —

Source record fields

fieldNames maps record fields to Select; callbacks return source data.

ru / moscow

Related Lists

Changing the country updates the available cities and resets the dependent value in the application handler.

{"value":0,"label":"Basic"}
[]

Meaning and label

labelInValue returns an object with value and label. Numeric ID 0 keeps its type.

svelte

Rich content and label text

Svelte snippets render options; optionLabelProp chooses a separate label for the control.

42

Custom selected label

labelRender explains a missing record while preserving the raw model and form value.

—

Extra action in the dropdown

popupRender retains the default menu and adds an action without losing editor focus.

reader

Styling Select parts

Prefix, classNames and styles extend shared ConfigProvider.select settings.

Icons and clearing

Shared icons and clearing from ConfigProvider.select; a local suffix reflects the field state.

["Svelte","TypeScript","HTML"]

Custom tag editor

components.input preserves tags and responsive overflow. Register connects the editor to Select focus and keyboard handling.

Replacing the entire field

components.root replaces the field with a button; the application supplies its label and styles, while Select manages the list.

[]

Remote search

Demo source with delay, cancel old request, pages, error and retry. Selected labels are saved when changing issues.

[]

Hide selected options

The selected tag keeps its label and onDeselect receives the original record after removal from options.

outlined
filled
borderless
underlined

Design options

Four single/multiple options and inheritance of the common filled from ConfigProvider.

Error and warning

status shows error or warning; the error is also indicated by aria-invalid.

Empty issue

notFoundContent accepts text, number, null or Svelte snippet for an empty list.

List container

getPopupContainer specifies the popup list container. The root Select is passed to getter after mount.

Select popup placement

placement sets the preferred corner, popupAlign adds a gap, and transitionName selects the animation. The popup can flip when space is limited.

Select popup width

true matches the control width; false fits the popup to its content. A number sets the width in px; a value smaller than the control does not narrow the popup.

Select from one to three teams.

Selected teams: 2.

Multiple selection in Form

The model stores an array of numeric identifiers. Form checks quantity, submits and resets selection.

["Svelte"]

Free tags

Tags creates strings without the required options; Enter and blur confirm the input.

[]
[]

Separators and input parsing

Separator array and whole string function; native parsing removes whitespace around the edges.

[0] maximum 2

Selection limitation

maxCount=2 limits new values; the selected option can be deselected.

["Svelte","TypeScript","Accessibility","Internationalization"]

Text and number of tags

Truncate captions, maxTagCount, and summary tag snippet retain full values.

["Svelte","TypeScript","JavaScript","HTML","CSS"]

Adaptive tags

maxTagCount=responsive measures width; hidden values ​​remain in FormData.

Options: 100000
["a10","c12"]

Large list

100000 options with virtual scrolling. scrollTo, focus and blur through SelectRef.

["Svelte","TypeScript","CSS"]

Own tags

tagRender uses Tag, label snippet and onClose; The summary tag is not removed.

Not selected

Description Items

optionRender gets source data and index; The label of the selected value remains text.

Closed; requests: []
Closed; requests: []

Opening control

bind:open and open/onOpenChange: The owner accepts or denies the request. An empty output retains the numeric content of 0.

[]

DefaultOpen is in effect on creation. Changing it later does not re-open the list.

Initial opening

defaultOpen is applied after mount; The SSR remains closed. Changing the initial prop does not reopen the list.

["docs"]
General: suite; local: project-select

Control, tags and popup follow prefixCls. Service variables share a common namespace regardless of local class and theme. The open list, search input and selection are saved.

CSS prefixes Select

Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.

Covering official examples

Checked against the live Select page in Ant Design 6.7.2. “In the application” means composing props, “Partial” means incomplete coverage, and “No API” means the feature is unavailable. Examples use the public package API.

27 themes of the official Select page
ant.design themeConditionExplanation
Basic UsageAvailable· ExampleSingle selection, disabled, loading and clearing.
Select with search fieldAvailable· ExampleSearch by label.
Custom SearchAvailable· ExamplePredicate filterOption.
Multi field searchAvailable· ExampleshowSearch.optionFilterProp searches for several fields using OR.
multiple selectionAvailable· ExampleArray of selected values.
SizesAvailable· ExampleThree sizes from the public API.
Custom dropdown optionsAvailable· ExampleoptionRender receives the source record and an index that includes group headings.
Search with sortAvailable· ExampleshowSearch.filterSort sorts the filtering result without changing options.
TagsAvailable· ExampleFree string values; options is optional.
Option GroupAvailable· ExampleOne level of groups, search, and navigation that skips disabled options.
coordinateIn the application· ExampleCommunication of two Selects through the application model.
Get value of selected itemAvailable· ExamplelabelInValue keeps value and label in the model and selection events.
Automatic tokenizationAvailable· ExampleArray of tokenSeparators for multiple/tags.
Custom tokenizationAvailable· ExampleThe tokenSeparators function receives the entire input string.
Search and Select UsersAvailable· ExampleGuided search and in-app download options.
Prefix and SuffixAvailable· Exampleprefix adds content before the field; suffix replaces the trailing area according to its state.
Custom dropdownAvailable· ExamplepopupRender extends the original menu through a Svelte snippet.
Hide Already SelectedAvailable· ExampleThe selected tag keeps its label and onDeselect receives the original record after removal from options.
VariantsAvailable· Exampleoutlined, filled, borderless and underlined for single/multiple, including inheritance from context.
Custom Tag RenderAvailable· ExampleSnippet receives a label, typed value and onClose; The summary tag is not removed.
Custom Selected Label RenderAvailable· ExampleA pure labelRender function returns text or a Svelte snippet.
Responsive maxTagCountAvailable· ExampleThe field width determines the visible tags; hidden meanings remain in the model and form.
Big DataAvailable· Example100000 options with measured virtual scrolling and scrollTo navigation.
StatusAvailable· Exampleerror and warning.
PlacementAvailable· ExampleFour physical popup corners, adjusted for available space.
Max CountAvailable· ExampleLimiting new values via maxCount in multiple/tags.
Custom semantic dom stylingAvailable· ExampleclassNames/styles support objects and functions, including ConfigProvider.select.

API

Below are the parameters of the installed package. The exact definitions are in public SelectProps, SelectOption and SelectSearchConfig. Single stores a string or number, multiple stores an array of the same type, tags additionally allows new strings.

Basic parameters Select
PropertyDescriptionTypeDefault
showActionThe focus value opens the list when the editor receives focus.readonly ("focus" | "click")[]—
virtualEnables list windowing; ConfigProvider.virtual applies without a local prop.booleanConfigProvider / true
listHeightMaximum inner viewport height in px; 0 removes the limit.number256
listItemHeightEstimated row height before measurement; 0 disables windowing.numbertoken.controlHeight
showScrollBarOptional displays the scrollbar during scrolling and hides it after 3 seconds.boolean | 'optional'optional
labelInValueThe model and events pass { value, label }; multiple/tags use arrays of objects.booleanfalse
optionLabelPropThe raw record field for the selected label. An explicit owner label takes priority.stringfieldNames.label
labelRenderA pure display function, including Snippet content. null/undefined falls back to the raw value.(info: SelectLabelRenderInfo) => RenderEmptyContentundefined
popupRenderA pure function receives the original menu; it also runs during SSR and while closed.SelectPopupRenderundefined
prefixContent before the editor. Falsy scalars, including 0, create no element.RenderEmptyContentundefined
rootClassNameA shared class for the control and popup; the existing class remains on the outer Select container.stringundefined
classNamesClasses for control and popup parts; local classes combine with ConfigProvider.select.SelectClassNames | ((info: SelectSemanticInfo) => SelectClassNames)undefined
stylesPart styles. A local popup leaf replaces the corresponding provider leaf entirely.SelectStyles | ((info: SelectSemanticInfo) => SelectStyles)undefined
styleA CSS object styles the control; a CSS string retains outer-container styling.SelectStyleundefined
defaultActiveFirstOptionActivates the first available option on opening and search changes.booleantrue
onActiveReports the active option or null; selection is a separate event.(value: Value | string | null) => void—
nativeElementThe root div or the registered components.root element after mount.RootElement | HTMLDivElement | undefinedundefined
inputElementThe native input or the registered components.input element after mount.EditorElement | HTMLInputElement | undefinedundefined
componentsInput replaces the editor; root replaces the whole field and takes priority. The snippet forwards attributes and registers the element with register. The extended API is partially ported.SelectComponents<RootElement, EditorElement>undefined
suffixReplaces the entire trailing area, including Form feedback. A pure function receives searchValue, open, focused, showSearch and loading; a nullish result restores the standard appearance.SelectRenderNode<SelectSuffixInfo>Standard icons
loadingIconLoading glyph in the standard suffix when loading=true.RenderEmptyContentFrom context
menuItemSelectedIconOption icon; a pure function receives value, disabled and isSelected.SelectRenderNode<SelectMenuItemIconInfo<Value>>From context
removeIconRemoval icon for a standard multiple/tags tag. Does not replace the button in tagRender.SelectRenderNode<undefined>From context
onInputKeyDownEditor keyboard event; preventDefault does not automatically cancel selection or tokenSeparators.(event: KeyboardEvent) => void—
prefixClsFull CSS prefix of the component and its parts. A non-empty local prop takes precedence; empty string and undefined inherit ConfigProvider. The namespace of the topic is set separately.stringConfigProvider.prefixCls + "-select"
variantLocal variant → closest Form.variant → ConfigProvider.select.variant → general ConfigProvider.variant → outlined.VariantFrom context / outlined
optionsSource records and one level of groups. fieldNames maps value/label/options fields.readonly OptionType[][]
fieldNamesSource field names for the value, label, children, and group heading.SelectFieldNamesvalue / label / options; groupLabel = label
valuebind:value links a value or array; labelInValue enables objects. null clears selection.SelectValueModel<Value, Mode, LabelInValue> | nullundefined
defaultValueThe initial model depends on mode and labelInValue; native reset restores it.Value | SelectLabelValue<Value> | readonly (Value | SelectLabelValue<Value>)[] | nullundefined
modeDefault single selection; multiple selects ready-made options, tags creates strings.multiple | tagsundefined
showSearchEnables search. The object configures the search string, callback and local filtering.boolean | SelectSearchConfig<Value, OptionType>multiple/tags: true; single: false
allowClearClearing: single → undefined, multiple/tags → []. The object sets clearIcon and label; the application translates the accessible name.boolean | SelectAllowClearConfigProvider.select / false
loadingShows indicator and aria-busy; request management remains in the application.booleanundefined
notFoundContentGeneral contents, including boolean and readonly arrays. null/false/empty string hides empty popup, 0 is visible; undefined inherits renderEmpty.RenderEmptyContentFrom context
sizelarge, medium or small; the usual height depends on the theme.ComponentSizeFrom context
statusVisual condition; error adds aria-invalid.error | warningFrom FormItem
disabledBlocks selection and excludes the native field from submission.booleanFrom context
placementPreferred popup placement. The provider popupOverflow sets the overflow calculation region; getPopupContainer selects the DOM container.bottomLeft | bottomRight | topLeft | topRightbottomLeft; in RTL bottomRight
popupAlignAnchor points, offsets, and overflow adjustment for the selected popup position.SelectPopupAlign—
builtinPlacementsMap of popup positions for placement values.Readonly<Record<string, SelectPopupAlign>>Built-in map
transitionNameName of the popup CSS animation.stringComponent animation
popupMatchSelectWidthtrue uses the control width, false fits the content, and a number sets the width in px. The control width remains the minimum; undefined inherits ConfigProvider. false disables virtualization.boolean | numberConfigProvider / true
getPopupContainerSelects the list DOM container. Without a getter, the existing parent is retained; the popup always uses a fixed native popover above the page.(trigger: HTMLElement) => HTMLElement | ShadowRootFrom context, otherwise the component parent
onPopupScrollNative scroll event from the inner viewport; currentTarget and this refer to its div.HTMLAttributes<HTMLDivElement>[onscroll]—
onValueChangeReceives the model after selection and clearing; onChange also provides record data.(value: SelectValueModel<Value, Mode, LabelInValue> | undefined) => void—
onChangeCalled when the selected values change. The second argument contains shallow copies of source records and {} for free tags without a source record.SelectProps<Value, Mode, OptionType, LabelInValue>["onChange"]—
onSelectEvery option selection, including repeated single selection without changing value.SelectProps<Value, Mode, OptionType, LabelInValue>["onSelect"]—
onDeselectRemoval of an individual value in multiple/tags. Clearing all values does not call it.SelectProps<Value, Mode, OptionType, LabelInValue>["onDeselect"]—
onClearUser clearing before onChange; single produces undefined, multiple/tags produces [].() => void—
onOpenChangeRequest to change visibility. When open, the owner accepts or rejects the request; initial and external updates do not trigger a callback.(open: boolean) => void—
openManaged visibility, including bind:open. Takes precedence over defaultOpen; The SSR remains closed.booleanundefined
defaultOpenInitial uncontrolled visibility after mount. Subsequent prop changes do not re-open the list.booleanfalse
classClass of the standard field’s outer container.string—
tokenSeparatorsAn array of delimiters or a function of the entire string. multiple accepts ready-made options; tags creates strings.SelectTokenSeparators—
maxCountMaximum of new selected multiple/tags values. An array already passed is not truncated.numberno limit
maxTagTextLengthLimits the visible tag text to UTF-16, preserving the full label and value; surrogate pair is not broken.numberno limit
maxTagCountLimits display only. responsive measures the width in the browser; SSR shows all values.number | responsiveall tags
maxTagPlaceholderScalar or Snippet with hidden SelectOmittedTag. null/undefined select default; false leaves an empty summary.SelectTagPlaceholder<Value>+ N ...
tagRenderContents of regular and summary tags multiple/tags. label - Snippet; summary does not have value, index and onClose.Snippet<[SelectTagInfo<Value>]>—
optionRenderData contains the source record, label has type unknown, and groupOption identifies group children.Snippet<[SelectFlattenOption<Value, OptionType>, { index: number }]>—

showSearch

Search settings Select
PropertyDescriptionTypeDefault
showSearch.searchIconSearch icon in the standard suffix of an open field.RenderEmptyContentFrom context
showSearch.searchValueManaged search string. The options list and selected values ​​are updated independently.stringundefined
showSearch.onSearchGets the custom search string; The application loads the data.(search: string) => void—
showSearch.filterOptionLocal filtering or predicate (search, option). For remote search, set it to false.boolean | predicatetrue
showSearch.optionFilterPropFields of the original option, combined via OR. The filterOption predicate takes precedence.string | readonly string[]single/multiple: label; tags: value
showSearch.filterSortSorts the filtered list, including synthetic tags, preserving the owner's options.(a, b, { searchValue }) => number—
showSearch.autoClearSearchValueClear local search when selected in multiple/tags. The managed searchValue updates the owner.booleantrue

In single/multiple search filters the list; tags creates free lines. optionFilterProp and filterSort are inside showSearch. For deleted data, set showSearch.filterOption=false and update options by showSearch.onSearch.

Context and native form

ConfigProvider.select only accepts variant. The local variant takes precedence over the nearest Form.variant, then the select.variant, global ConfigProvider.variant and outlined are applied. Size and appearance settings do not change the selected values.

Size and availability are inherited from ConfigProvider and Form. id, name, required, aria-* and native events are passed to input. FormData contains strings, model contains the original value types.

Methods

bind:this provides SelectRef with focus, blur and scrollTo methods.

bind:nativeElement provides the root; bind:inputElement provides the editor.

open supports bind:open and controlled open/onOpenChange; defaultOpen sets the initial state after mount. Associate the control with an HTML label through id and use the keyboard.

MethodTypeApplication
focus(options?: FocusOptions) => voidFocuses the editor.
blur() => voidBlurs the editor.
scrollTo(config?: SelectScrollConfig | null) => voidScrolls the list by index, key or top/left position.

Large list demonstrates jumping to the last option after opening the popup.

Semantic DOM

classNames and styles style Select and popup parts through an object or pure function. ConfigProvider.select provides shared values; rootClassName applies to the control and popup. Styling Select parts.

root / prefix / suffix / input / placeholder / content / item / itemContent / itemRemove / clear / popup.root / popup.list / popup.listItem

Registration tokens

Component tokens are transferred via ConfigProvider.theme.components.Select.

<script lang="ts">
  import { ConfigProvider, Select } from '@woodger/antd';
</script>

<ConfigProvider theme={{
  cssVar: {},
  components: {
    Select: {
      activeBorderColor: '#389e0d',
      hoverBorderColor: '#73d13d',
      optionSelectedBg: '#f6ffed',
      optionSelectedColor: '#237804'
    }
  }
}}>
  <Select aria-label={("Custom theme Select")} defaultValue="day" options={([
      { value: 'day', label: "Day" },
      { value: 'week', label: "Week" },
      { value: 'month', label: "Month" }
    ])} />
</ConfigProvider>
Select Component Tokens
TokenPurpose
activeBorderColorFrame color when focused.
activeOutlineColorFocus outline color.
clearBgClean button background.
hoverBorderColorHover frame.
multipleItemBgBackground of the selected tag.
multipleItemBorderColorFrame of the selected tag.
multipleItemBorderColorDisabledFrame of an inaccessible tag.
multipleItemColorDisabledText of an inaccessible tag.
multipleItemHeightNormal tag height.
multipleItemHeightLGLarge tag height.
multipleItemHeightSMSmall tag height.
multipleSelectorBgDisabledBackground of inaccessible multiple Select.
optionActiveBgBackground of the active variant.
optionFontSizeOption text size.
optionHeightHeight option.
optionLineHeightVariant row height.
optionPaddingOption indents.
optionSelectedBgBackground of the selected option.
optionSelectedColorText of the selected option.
optionSelectedFontWeightText thickness of the selected option.
selectorBgField background.
showArrowPaddingInlineEndPlace for arrow.
singleItemHeightLGHeight of a large single value.
zIndexPopupList layer.

Common tokens of the current topic

Values are read through theme.useToken() and change along with the settings in the header.

Common tokens of the current topic
TokenPurposeCurrent value
colorBgContainerBackground of a regular field.#ffffff
colorBgContainerDisabledBackground of the inaccessible icon.rgba(0,0,0,0.04)
colorBgElevatedDropdown background.#ffffff
colorBorderFrame color.#d9d9d9
colorBorderDisabledFrame of an inaccessible element.#d9d9d9
colorErrorPrimary color of the error.#ff4d4f
colorErrorAffixColor of additions when there is an error.#ff4d4f
colorErrorBgError background.#fff2f0
colorErrorBgHoverHover error background.#fff1f0
colorErrorBorderHoverHover error frame.#ffa39e
colorErrorOutlineError circuit.rgba(255,38,5,0.06)
colorErrorTextError text.#ff4d4f
colorFillQuaternaryWeak filling.rgba(0,0,0,0.02)
colorFillSecondarySecondary filling.rgba(0,0,0,0.06)
colorFillTertiaryTertiary fill.rgba(0,0,0,0.04)
colorIconIcon color.rgba(0,0,0,0.45)
colorIconHoverColor of icons when hovering.rgba(0,0,0,0.88)
colorPrimaryPrimary color of interactive states.#2f54eb
colorPrimaryBorderLight outline of the main color.#adc6ff
colorSplitSeparator color.rgba(5,5,5,0.06)
colorTextLabel color.rgba(0,0,0,0.88)
colorTextDescriptionDescription color.rgba(0,0,0,0.45)
colorTextDisabledColor of unavailable label.rgba(0,0,0,0.25)
colorTextPlaceholderInput prompt color.rgba(0,0,0,0.25)
colorTextQuaternarySecondary text color.rgba(0,0,0,0.25)
colorWarningPrimary warning color.#faad14
colorWarningAffixColor warning additions.#faad14
colorWarningBgWarning background.#fffbe6
colorWarningBgHoverHover alert background.#fff1b8
colorWarningHoverHover alert color.#ffd666
colorWarningOutlineWarning circuit.rgba(255,215,5,0.1)
borderRadiusNormal rounding.6
borderRadiusLGLarge rounding.8
borderRadiusSMIcon rounding.4
borderRadiusXSMinimum rounding.2
boxShadowSecondaryDrop-down shadow. 0 6px 16px 0 rgba(0,0,0,0.08), 0 3px 6px -4px rgba(0,0,0,0.12), 0 9px 28px 8px rgba(0,0,0,0.05)
controlHeightNormal field height.32
controlHeightLGLarge field height.40
controlHeightSMHeight of the small field.24
controlItemBgActiveHoverBackground of the selected item when hovering.#d6e4ff
controlOutlineWidthThickness of the element outline.2
controlPaddingHorizontalHorizontal padding of the element.12
fontFamilyFont family.-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontSizeBasic text size.14
fontSizeIconIcon size.12
fontSizeLGLarge text size.16
fontSizeSMSmall text size.12
lineHeightLabel line height.1.5714285714285714
lineHeightLGLarge line height.1.5
lineTypeFrame line type.solid
lineWidthFrame thickness.1
marginXSSmall external indent.8
motionDurationMidDuration of main transitions.0.2s
motionDurationSlowDuration of slow transitions.0.3s
motionEaseInOutSmooth transition curve.cubic-bezier(0.645, 0.045, 0.355, 1)
motionEaseInOutCircTransition curve.cubic-bezier(0.78, 0.14, 0.15, 0.86)
motionEaseInQuintTransition acceleration curve.cubic-bezier(0.755, 0.05, 0.855, 0.06)
motionEaseOutCircTransition deceleration curve.cubic-bezier(0.08, 0.82, 0.17, 1)
motionEaseOutQuintTransition deceleration curve.cubic-bezier(0.23, 1, 0.32, 1)
paddingSMSmall internal indent.12
paddingXSIndentation of the label from the icon.8
paddingXXSMinimum internal space.4

FAQ

Why doesn't entering text change the selected value?

In single/multiple, the search filters options; confirmation changes value. For an array of free strings, select mode="tags", for one arbitrary text - AutoComplete. Keyboard search shows the selection with arrows and Enter.

Why is the cleaning result undefined or []?

These are single and multiple field formats. The value 0 remains a valid choice. Numerical example allows you to check signature, original type and cleanup.

How to get the signature of the selected option?

Value and label demonstrates labelInValue: the model contains value and label, and numeric values keep their type. With remote data, retain the records the application needs even when the current result page changes.

Why are deleted results not shown?

Check showSearch.filterOption=false, the current search string and the data in options. The old response should not replace the result of the new request. Undo, error and redo handling can be explored in independent example.

Why does the signature remain after deleting an option from options?

Select keeps the labels of selected values when options change. To clear a selection from the application, update value.

Where is the drop down list?

Without a getter, the DOM parent remains inside the component, but the list is displayed as a fixed native popover above the page. Local getPopupContainer or ConfigProvider.getPopupContainer moves the DOM to another container. The container example demonstrates this composition. open controls visibility; placement selects the preferred corner.

Is Select suitable for a very large list?

Select uses virtual scrolling. The accessible listbox contains the active option and its neighbors, while the visible window contains measured rows. Applications needing the complete option DOM for assistive technology can set virtual=false. The large list demonstrates 100000 options.