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.
Local and remote search
To search using a ready-made list, enable showSearch. The standard single/multiple filter searches by label, tags - by value. showSearch.optionFilterProp accepts one field or several via OR, as in example name and email. The native showSearch.filterOption receives the string and the original option and takes precedence over the field selection.
The search string and the selected value are different states. showSearch.searchValue controls search text, showSearch.onSearch reports user input, and bind:value or onValueChange refers to selection. showSearch.filterSort gets the two original option records and the current searchValue; sorts the filtering result, including synthetic tags, without changing the owner array. Sorting example first shows the match at the beginning of the name.
During a remote search, the options are already filtered by the data source. Set showSearch.filterOption=false, otherwise the local filter may re-hide the received records. Execute the request from the showSearch.onSearch handler; The library does not select transport and does not add debounce.
Self-contained remote search example links search, cancel previous request, late response protection, error and retry. Scrolling onPopupScroll is used by the application for the next page. When unmounted, the example frees the timer and cancels the request.
loading shows waiting. Empty output and source error are different situations: set the appropriate notFoundContent and offer replay where it is needed. Select remembers the labels of the selected values, so a new output should not erase the selection already made.
Size, variant and availability can be coordinated through ConfigProvider. Use Select design tokens from the token reference for theming and classNames and styles for individual parts. The styling example combines shared settings with local changes.
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
Main choice
Single selection, disabled, loading and allowClear. The value is associated with the model via bind:value.
<script lang="ts">
import { Select } from '@woodger/antd';
let value = $state<string | undefined>('lucy');
const options = [
{ value: 'jack', label: 'Jack' },
{ value: 'lucy', label: 'Lucy' },
{ value: 'disabled', label: "Unavailable option", disabled: true },
{ value: 'yiminghe', label: 'Yiminghe' }
];
</script>
<style>
.example {
display: grid;
gap: 20px;
}
.fields {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16px;
}
output { color: var(--ant-color-text-secondary); }
@media (max-width: 560px) { .fields { grid-template-columns: minmax(0, 1fr); } }
</style>
<div class="example">
<div class="fields">
<Select options={(options)} bind:value aria-label={("Basic Select")} />
<Select options={(options)} defaultValue="lucy" disabled aria-label={("Unavailable Select")} />
<Select options={(options)} defaultValue="lucy" loading aria-label={("Loading Select")} />
<Select options={(options)} defaultValue="lucy" allowClear aria-label={("Cleanable Select")} />
</div>
<output aria-label={("Basic Select value")}>{(value ?? 'undefined')}</output>
</div>
Search in the list
showSearch enables searching by name, and showAction opens the list on focus. Use the arrow keys, Enter, and Escape to control the list.
<script lang="ts">
import { Select } from '@woodger/antd';
let value = $state<string>();
const options = ['Jack', 'Lucy', 'Tom'].map(label => ({ value: label, label }));
</script>
<style>
.example {
display: grid;
gap: 20px;
}
output { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
<Select
options={(options)}
bind:value
showSearch
showAction={['focus']}
allowClear
placeholder={("Find a member")}
aria-label={("Search in Select")}
/>
<output aria-label={("Search result Select")}>{(value
?? ("Nothing selected"))}</output>
</div>
Own filtering
filterOption in the showSearch object searches by the beginning of the name, and not by the occurrence of the substring.
<script lang="ts">
import { Select } from '@woodger/antd';
const options = ['Apple', 'Apricot', 'Pear', 'Pineapple'].map(label => ({ value: label, label }));
</script>
<Select
options={(options)}
aria-label={("Search by beginning of name")}
placeholder={("Enter the beginning of the name")}
showSearch={{
filterOption: (search, option) =>
option.label.toLowerCase().startsWith(search.toLowerCase())
}}
/>
Search by multiple fields
showSearch.optionFilterProp searches for source options by label and email.
<script lang="ts">
import { Select } from '@woodger/antd';
const people = [
{ id: 0, name: "Anna", email: 'anna@example.test' },
{ id: 1, name: "Boris", email: 'boris@example.test' },
{ id: 2, name: "Vera", email: 'vera@example.test' }
];
const options = people.map(person => ({
value: person.id,
label: person.name,
email: person.email
}));
</script>
<Select
options={(options)}
aria-label={("Search by name or email")}
placeholder={("Name or email")}
showSearch={{ optionFilterProp: ['label', 'email'] }}
/>
Multiple choice
mode="multiple" binds an array of ready-made values. Selected items can be deleted or cleared entirely.
<script lang="ts">
import { Select } from '@woodger/antd';
let value = $state<string[]>(['a', 'c']);
const options = [
{ value: 'a', label: "Development" },
{ value: 'b', label: "Design" },
{ value: 'c', label: "Analytics" },
{ value: 'd', label: "Archive", disabled: true }
];
</script>
<style>
.example {
display: grid;
gap: 20px;
}
output {
color: var(--ant-color-text-secondary);
overflow-wrap: anywhere;
}
</style>
<div class="example">
<Select
options={(options)}
mode="multiple"
bind:value
allowClear
aria-label={("Multiple Select")}
placeholder={("Select commands")}
/>
<output aria-label={("Select array")}>{JSON.stringify(value)}</output>
</div>
Three sizes
large, medium and small. Without local size, ConfigProvider.componentSize is valid.
<script lang="ts">
import { Select } from '@woodger/antd';
const options = ['Jack', 'Lucy', 'Tom'].map(label => ({ value: label, label }));
const sizes = ['large', 'medium', 'small'] as const;
</script>
<style>
.example {
display: grid;
gap: 20px;
}
</style>
<div class="example">
{#each sizes as size (size)}
<Select options={(options)} {size} defaultValue="Lucy" aria-label={("Size Select " + String((size)) + "")} />
{/each}
</div>
Search with sorting
showSearch.filterSort sorts the result: first the match at the beginning of the name, then the alphabet.
<script lang="ts">
import { Select } from '@woodger/antd';
const options = ['React', 'Preact', 'Svelte', 'Angular'].map(label => ({ value: label, label }));
</script>
<Select
options={(options)}
aria-label={("Search with sorting")}
placeholder={("Try re")}
showSearch={{
filterSort: (left, right, { searchValue }) => {
const query = searchValue.toLowerCase();
const prefix = Number(!left.label.toLowerCase().startsWith(query))
- Number(!right.label.toLowerCase().startsWith(query));
return prefix || left.label.localeCompare(right.label);
}
}}
/>
Option groups
Groups, label search, a disabled option, and repeated onSelect events.
<script lang="ts">
import { Select } from '@woodger/antd';
const options = [
{
label: "Development",
options: [
{
value: 'svelte',
label: 'Svelte',
title: 'Svelte 5',
className: 'framework-option',
style: { fontWeight: 600 },
'data-technology': 'svelte'
},
{ value: 'typescript', label: 'TypeScript' }
]
},
{
label: "Design",
options: [
{ value: 'figma', label: 'Figma' },
{ value: 'sketch', label: 'Sketch', disabled: true }
]
}
];
let value = $state<string | undefined>('svelte');
let selections = $state(0);
</script>
<style>
.example {
display: grid;
gap: 12px;
min-width: 0;
}
output {
color: var(--ant-color-text-secondary);
overflow-wrap: anywhere;
}
</style>
<div class="example">
<Select
options={(options)}
bind:value
showSearch={{ optionFilterProp: 'label' }}
onSelect={() => { selections += 1; }}
aria-label={("Select with groups")}
style="width:100%"
/>
<output aria-label={("Grouped Select value")}>{value ?? '—'}</output>
<output aria-label={("Select selection count")}>
{("Selections: ")}{selections}
</output>
</div>
Source record fields
fieldNames maps record fields to Select; callbacks return source data.
<script lang="ts">
import { Button, Select } from '@woodger/antd';
interface Person {
key: string;
code?: number;
caption?: string;
department?: string;
members?: readonly Person[];
profile?: { email: string };
}
const PeopleSelect = Select<number, 'multiple', Person>;
const groups: readonly Person[] = [
{
key: 'engineering',
department: ("Development"),
members: [
{
key: 'anna',
code: 0,
caption: ("Anna"),
profile: { email: 'anna@example.com' }
},
{
key: 'boris',
code: 1,
caption: ("Boris"),
profile: { email: 'boris@example.com' }
}
]
},
{
key: 'design',
department: ("Design"),
members: [
{
key: 'elena',
code: 2,
caption: ("Elena"),
profile: { email: 'elena@example.com' }
}
]
}
];
let value = $state<number[]>([0]);
let hidden = $state<number[]>([]);
let events = $state<string[]>([]);
const options = $derived(groups.map(group => ({
...group,
members: group.members?.filter(person =>
person.code === undefined || !hidden.includes(person.code)
)
})));
function record(
event: 'change' | 'select' | 'deselect' | 'clear',
next?: number | number[],
option?: Person | Person[]
) {
const entry = JSON.stringify({ event, value: next, option });
events = [...events.slice(-5), entry];
}
</script>
<style>
.example {
display: grid;
gap: 16px;
min-width: 0;
}
.actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
}
output {
white-space: pre-wrap;
overflow-wrap: anywhere;
}
</style>
<div class="example">
<PeopleSelect
{options}
bind:value
mode="multiple"
fieldNames={{ value: 'code', label: 'caption', options: 'members', groupLabel: 'department' }}
showSearch={{ optionFilterProp: ['caption', 'department'] }}
allowClear
onChange={(next, option) => record('change', next, option)}
onSelect={(next, option) => record('select', next, option)}
onDeselect={(next, option) => record('deselect', next, option)}
onClear={() => record('clear')}
aria-label={("Select with record fields")}
style="width:100%"
/>
<div class="actions">
<Button disabled={value.length === 0} onclick={() => { hidden = [...value]; }}>
{("Hide selected records")}
</Button>
<Button disabled={hidden.length === 0} onclick={() => { hidden = []; }}>
{("Restore all records")}
</Button>
<Button onclick={() => { events = []; }}>{("Clear Select log")}</Button>
</div>
<output
aria-label={("Selected Select record codes")}
>{JSON.stringify(value)}</output>
<output aria-label={("Select events with custom data")}>
{events.join('\n') || '—'}
</output>
</div>
Related Lists
Changing the country updates the available cities and resets the dependent value in the application handler.
<script lang="ts">
import { Select, type SelectOption } from '@woodger/antd';
const cities = {
ru: [{ value: 'moscow', label: "Moscow" }, { value: 'kazan', label: "Kazan" }],
fr: [{ value: 'paris', label: "Paris" }, { value: 'lyon', label: "Lyon" }]
};
let country = $state<'ru' | 'fr'>('ru');
let city = $state('moscow');
const countries: SelectOption<'ru' | 'fr'>[] = [
{ value: 'ru', label: "Russia" }, { value: 'fr', label: "France" }
];
</script>
<style>
.example {
display: grid;
gap: 20px;
}
output { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
<Select aria-label={("Country Select")} value={country} options={(countries)} onValueChange={value => {
if (!value) {
return;
}
country = value;
city = cities[value][0].value;
}} />
<Select
aria-label={("City Select")}
options={(cities[country])}
bind:value={city}
/>
<output aria-label={("Associated Values Select")}>{country} / {city}</output>
</div>
Meaning and label
labelInValue returns an object with value and label. Numeric ID 0 keeps its type.
<script lang="ts">
import { Select, type SelectLabelValue } from '@woodger/antd';
interface Plan {
value: number;
label: string;
}
const PlanSelect = Select<number, undefined, Plan, true>;
const MultiplePlanSelect = Select<number, 'multiple', Plan, true>;
const options = [{ value: 0, label: "Basic" }, { value: 1, label: "Command" }];
let value = $state<SelectLabelValue<number> | undefined>({
value: 0,
label: ("Basic")
});
let plans = $state<SelectLabelValue<number>[]>([]);
</script>
<style>
.example {
display: grid;
gap: 20px;
}
output {
color: var(--ant-color-text-secondary);
overflow-wrap: anywhere;
}
</style>
<div class="example">
<PlanSelect
options={(options)}
bind:value
labelInValue
allowClear
aria-label={("Receiving label Select")}
/>
<output
aria-label={("Meaning and label Select")}
>{JSON.stringify(value ?? {})}</output>
<MultiplePlanSelect
options={(options)}
bind:value={plans}
labelInValue
mode="multiple"
allowClear
aria-label={("Labeled multiple Select values")}
/>
<output aria-label={("Select labeled value array")}>
{JSON.stringify(plans)}
</output>
</div>
Rich content and label text
Svelte snippets render options; optionLabelProp chooses a separate label for the control.
<script lang="ts">
import { Select, Checkbox } from '@woodger/antd';
let value = $state<string>('svelte');
let plainLabel = $state(true);
const options = $derived([
{ value: 'svelte', label: svelteLabel, caption: 'Svelte 5' },
{ value: 'typescript', label: typescriptLabel, caption: 'TypeScript' }
]);
</script>
<style>
.example {
display: grid;
gap: 16px;
}
.label {
display: inline-flex;
align-items: baseline;
gap: 8px;
}
small, output { color: var(--ant-color-text-secondary); }
</style>
{#snippet svelteLabel()}
<span class="label" data-rich-label="svelte">
<strong>Svelte</strong><small>{("Reactive interface")}</small>
</span>
{/snippet}
{#snippet typescriptLabel()}
<span class="label" data-rich-label="typescript">
<strong>TypeScript</strong><small>{("Type checking")}</small>
</span>
{/snippet}
<div class="example">
<Checkbox bind:checked={plainLabel}>
{("Use a text label for the selected option")}
</Checkbox>
<Select
{options}
bind:value
optionLabelProp={plainLabel ? 'caption' : undefined}
showSearch={{ optionFilterProp: 'caption' }}
aria-label={("Select with rich labels")}
/>
<output aria-label={("Rich label Select value")}>{value}</output>
</div>
Custom selected label
labelRender explains a missing record while preserving the raw model and form value.
<script lang="ts">
import { Button, Select, type SelectLabelRenderInfo } from '@woodger/antd';
const NumberSelect = Select<number>;
const options = [{ value: 0, label: "Basic" }, { value: 1, label: "Command" }];
let value = $state<number | undefined>(42);
function renderLabel(info: SelectLabelRenderInfo<number>) {
return typeof info.label === 'string' ? info.label : missingLabel;
}
</script>
<style>
.example {
display: grid;
gap: 16px;
}
.missing {
display: inline-flex;
gap: 8px;
}
small, output { color: var(--ant-color-text-secondary); }
</style>
{#snippet missingLabel()}
<span class="missing" data-missing-label>
<strong>№ {value}</strong><small>{("Record unavailable")}</small>
</span>
{/snippet}
<form class="example">
<NumberSelect
options={(options)}
bind:value
labelRender={renderLabel}
name="plan"
aria-label={("Select with a custom selected label")}
/>
<Button onclick={() => { value = 42; }}>{("Show the missing record")}</Button>
<output aria-label={("Select custom label value")}>{value}</output>
</form>
Extra action in the dropdown
popupRender retains the default menu and adds an action without losing editor focus.
<script lang="ts">
import type { Snippet } from 'svelte';
import { Button, Divider, Select } from '@woodger/antd';
let value = $state<string>();
let added = $state(0);
let options = $state([{ value: 'first', label: ("First option") }]);
function addOption() {
added += 1;
const label = ("" + String((added)) + ". New option");
options = [...options, { value: `new-${added}`, label }];
}
</script>
<style>
.footer {
display: flex;
justify-content: space-between;
align-items: center;
gap: 8px;
}
output {
display: block;
margin-top: 12px;
color: var(--ant-color-text-secondary);
}
</style>
{#snippet popupContent(origin: Snippet)}
{@render origin()}
<Divider style="margin: 8px 0;" />
<div class="footer">
<Button
type="text"
onmousedown={event => { event.preventDefault(); }}
onclick={addOption}
>{("Add an option")}</Button>
<span>{added}</span>
</div>
{/snippet}
<Select
{options}
bind:value
popupRender={() => popupContent}
aria-label={("Select with an extra action")}
/>
<output aria-label={("Custom Select popup selection")}>{value ?? '—'}</output>
Styling Select parts
Prefix, classNames and styles extend shared ConfigProvider.select settings.
<script lang="ts">
import { Checkbox, ConfigProvider, Select } from '@woodger/antd';
let value = $state<string | undefined>('reader');
let warning = $state(false);
const options = [{ value: 'reader', label: "Reader" }, { value: 'editor', label: "Editor" }];
</script>
<style>
.example {
display: grid;
gap: 16px;
}
output { color: var(--ant-color-text-secondary); }
</style>
<div class="example">
<Checkbox bind:checked={warning}>{("Warning status")}</Checkbox>
<ConfigProvider select={{
allowClear: true,
showSearch: true,
classNames: { root: 'shared-select', popup: { root: 'shared-select-popup' } },
styles: { root: { borderRadius: 12 }, popup: { root: { borderRadius: 12 } } }
}}>
<Select
options={(options)}
bind:value
prefix={("Role")}
status={warning ? 'warning' : undefined}
rootClassName="role-select"
classNames={({ props }) => ({ root: props.status === 'warning' ? 'role-warning' : '' })}
styles={{
prefix: { color: 'var(--ant-color-text-secondary)' },
popup: { listItem: { paddingInline: 16 } }
}}
aria-label={("Select with semantic styles")}
/>
</ConfigProvider>
<output aria-label={("Styled Select value")}>{value ?? '—'}</output>
</div>
Icons and clearing
Shared icons and clearing from ConfigProvider.select; a local suffix reflects the field state.
<script lang="ts">
import { Checkbox, ConfigProvider, Select, type SelectSuffixInfo } from '@woodger/antd';
const options = ['Svelte', 'TypeScript', 'CSS'].map(label => ({ value: label, label }));
let values = $state(['Svelte']);
let value = $state<string | undefined>('TypeScript');
let loading = $state(false);
</script>
<style>
.example {
display: grid;
gap: 16px;
}
.fields {
display: grid;
gap: 12px;
}
svg {
display: block;
width: 1em;
height: 1em;
}
.spinner { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
</style>
{#snippet searchIcon()}
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" aria-hidden="true">
<circle cx="6.5" cy="6.5" r="4.5" /><path d="m10 10 4 4" />
</svg>
{/snippet}
{#snippet loadingIcon()}
<svg class="spinner" viewBox="0 0 16 16" fill="none" stroke="currentColor" aria-hidden="true">
<path d="M8 2a6 6 0 1 1-6 6" />
</svg>
{/snippet}
{#snippet arrow()}
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" aria-hidden="true">
<path d="m3 6 5 5 5-5" />
</svg>
{/snippet}
<div class="example">
<Checkbox bind:checked={loading}>{("Show loading")}</Checkbox>
<ConfigProvider select={{
loadingIcon,
showSearch: { searchIcon },
menuItemSelectedIcon: ({ isSelected }) => isSelected ? '✓' : null,
removeIcon: '−',
allowClear: { clearIcon: '×', label: ("Clear technologies") }
}}>
<div class="fields">
<Select
mode="multiple"
{options}
bind:value={values}
{loading}
aria-label={("Technologies with custom icons")}
/>
<Select
{options}
bind:value
{loading}
allowClear={{ label: ("Clear the primary language") }}
suffix={(info: SelectSuffixInfo) => {
if (info.loading) {
return loadingIcon;
}
return info.open ? searchIcon : arrow;
}}
aria-label={("Primary language with a custom suffix")}
/>
</div>
</ConfigProvider>
</div>
Custom tag editor
components.input preserves tags and responsive overflow. Register connects the editor to Select focus and keyboard handling.
<script lang="ts">
import {
Button, Select, Tag, type SelectInputContext, type SelectRef, type SelectTagInfo
} from '@woodger/antd';
const options = ['Svelte', 'TypeScript', 'JavaScript', 'HTML', 'CSS']
.map(label => ({ value: label, label }));
let values = $state(['Svelte', 'TypeScript', 'HTML']);
let width = $state(480);
let control = $state<SelectRef>();
</script>
<style>
.example {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 12px;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
output { overflow-wrap: anywhere; }
</style>
{#snippet editor({ attributes, register }: SelectInputContext)}
<input {...attributes} {@attach register} />
{/snippet}
{#snippet tag(info: SelectTagInfo<string>)}
<Tag
color={info.isMaxTag ? undefined : 'blue'}
closable={info.closable}
disabled={info.disabled}
onClose={info.onClose}
closeLabel={`${("Remove tag")} ${info.value}`}
style="margin-inline-end: 4px"
onmousedown={event => {
event.preventDefault();
event.stopPropagation();
}}
>{@render info.label()}</Tag>
{/snippet}
<div class="example">
<div class="controls">
<Button onclick={() => { width = 220; }}>{("Narrow field")}</Button>
<Button onclick={() => { width = 480; }}>{("Wide field")}</Button>
<Button onclick={() => control?.focus()}>{("Focus the editor")}</Button>
</div>
<div style={`
width: ${width}px;
max-width: 100%;
`}>
<Select
mode="tags"
{options}
bind:value={values}
bind:this={control}
components={{ input: { render: editor, props: { style: { fontFamily: 'monospace' } } } }}
maxTagCount="responsive"
tagRender={tag}
aria-label={("Tags in a custom editor")}
/>
</div>
<output aria-label={("Custom editor values")}>
{JSON.stringify(values)}
</output>
</div>
Replacing the entire field
components.root replaces the field with a button; the application supplies its label and styles, while Select manages the list.
<script lang="ts">
import { Button, Select, type SelectRootContext } from '@woodger/antd';
const options = [{ value: 'reader', label: "Reader" }, { value: 'editor', label: "Editor" }];
let value = $state<string | undefined>('reader');
let open = $state(false);
let root = $state<HTMLButtonElement | HTMLDivElement>();
const selected = $derived(options.find(option => option.value === value));
const label = $derived(selected?.label ?? "Choose a role");
</script>
<style>
.example {
display: grid;
gap: 12px;
}
.trigger {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
width: 100%;
padding: 8px 12px;
font: inherit;
cursor: pointer;
color: var(--ant-color-text);
background: var(--ant-color-bg-container);
border: 1px solid var(--ant-color-border);
border-radius: var(--ant-border-radius);
}
.trigger:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
</style>
{#snippet field({ attributes, register }: SelectRootContext<HTMLButtonElement>)}
<button
{...attributes}
type="button"
class="trigger"
aria-haspopup="listbox"
aria-expanded={open}
{@attach register}
>
{(label)}<span aria-hidden="true">⌄</span>
</button>
{/snippet}
<div class="example">
<Select
options={(options)}
bind:value
bind:open
bind:nativeElement={root}
components={{ root: field }}
showSearch={false}
aria-label={("Role through a custom field")}
/>
<Button onclick={() => root?.focus()}>{("Focus the custom field")}</Button>
</div>
Remote search
Demo source with delay, cancel old request, pages, error and retry. Selected labels are saved when changing issues.
<script lang="ts">
import { onMount } from 'svelte';
import { Button, Select, type SelectOption } from '@woodger/antd';
const people = Array.from({ length: 40 }, (_, index) => ({
value: index,
label: `Member ${String(index + 1).padStart(2, '0')}`
}));
let selected = $state<number[]>([]);
let options = $state<SelectOption<number>[]>([]);
let search = $state('');
let loading = $state(false);
let error = $state('');
let total = $state(0);
let alive = false;
let failNext = false;
let request = 0;
let timer: ReturnType<typeof setTimeout> | undefined;
const hasMore = $derived(options.length < total);
function load(query: string, more = false) {
if (!alive || more && loading) {
return;
}
clearTimeout(timer);
const current = ++request;
const offset = more ? options.length : 0;
search = query;
loading = true;
error = '';
if (!more) options = [];
timer = setTimeout(() => {
if (!alive || current !== request) {
return;
}
loading = false;
if (failNext) {
failNext = false;
error = ("Failed to load participants.");
return;
}
const matches = people.filter(person => person.label.toLowerCase().includes(
query.toLowerCase()
));
total = matches.length;
options = [...(more ? options : []), ...matches.slice(offset, offset + 8)];
}, 250);
}
onMount(() => {
alive = true;
load('');
return () => {
alive = false;
request += 1;
clearTimeout(timer);
};
});
</script>
<style>
.example {
display: grid;
gap: 20px;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
output {
color: var(--ant-color-text-secondary);
overflow-wrap: anywhere;
}
.error {
margin: 0;
color: var(--ant-color-error);
}
</style>
{#snippet empty()}<span role="status">{loading ? ("Loading participants...") : (error
|| ("No members found"))}</span>{/snippet}
<div class="example">
<Select
options={(options)}
mode="multiple"
bind:value={selected}
aria-label={("Remote Search Select")}
showSearch={{ searchValue: search, onSearch: value => load(value), filterOption: false }}
{loading}
status={error ? 'error' : undefined}
notFoundContent={(empty)}
allowClear
placeholder={("Find a member")}
onPopupScroll={event => {
const list = event.currentTarget;
if (hasMore && list.scrollTop + list.clientHeight >= list.scrollHeight - 16) {
load(search, true);
}
}}
/>
<div class="actions">
<Button disabled={!hasMore || loading} onclick={() => load(search, true)}>
{("More Select members")}
</Button>
<Button onclick={() => {
failNext = true;
load(search);
}}>{("Simulate Select error")}</Button>
{#if error}<Button
onclick={() => load(search)}
>{("Repeat Select request")}</Button>{/if}
</div>
{#if error}<p class="error" role="alert">{error}</p>{/if}
<output
aria-label={("Selected members Select")}
>{JSON.stringify(selected)}</output>
</div>
Hide selected options
The selected tag keeps its label and onDeselect receives the original record after removal from options.
<script lang="ts">
import { Select } from '@woodger/antd';
let selected = $state<string[]>([]);
let removed = $state('');
const source = [
{ value: 'apple', label: "Apple", sku: 'A-01' },
{ value: 'pear', label: "Pear", sku: 'P-02' },
{ value: 'orange', label: "Orange", sku: 'O-03' }
];
const options = $derived(source.filter(option => !selected.includes(option.value)));
</script>
<style>
.example {
display: grid;
gap: 20px;
}
output {
color: var(--ant-color-text-secondary);
overflow-wrap: anywhere;
}
</style>
<div class="example">
<Select options={(options)} bind:value={selected} mode="multiple" allowClear
onDeselect={(_, option) => removed = option.sku}
aria-label={("Hide selected options")} notFoundContent={("All options selected")} />
<output aria-label={("Hidden Options Select")}>{JSON.stringify(selected)}</output>
{#if removed}
<output aria-label={("Original record")}>{removed}</output>
{/if}
</div>
Design options
Four single/multiple options and inheritance of the common filled from ConfigProvider.
<script lang="ts">
import { Checkbox, ConfigProvider, Select } from '@woodger/antd';
import type { Variant } from '@woodger/antd';
const variants: readonly Variant[] = ['outlined', 'filled', 'borderless', 'underlined'];
const options = [{ value: 'anna', label: "Anna" }, { value: 'boris', label: "Boris" }];
let explicit = $state(true);
let value = $state<string | undefined>('anna');
let values = $state<string[]>(['anna']);
</script>
<style>
.settings { margin-bottom: 24px; }
.examples {
display: grid;
gap: 24px;
}
.row {
display: grid;
gap: 8px;
min-width: 0;
}
.pair {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
</style>
<div
class="settings"
><Checkbox
bind:checked={explicit}
>{("Local options Select")}</Checkbox></div>
<ConfigProvider variant="filled">
<div class="examples">
{#each variants as variant (variant)}
<div class="row">
<span>{(variant)}</span>
<div class="pair">
<Select options={(options)} bind:value variant={explicit
? variant
: undefined}
aria-label={("Single Select " + String((variant)) + "")} />
<Select
options={(options)}
mode="multiple"
bind:value={values}
variant={explicit ? variant : undefined}
aria-label={("Multiple Select " + String((variant)) + "")}
/>
</div>
</div>
{/each}
</div>
</ConfigProvider>
Error and warning
status shows error or warning; the error is also indicated by aria-invalid.
<script lang="ts">
import { Select } from '@woodger/antd';
const options = ['Jack', 'Lucy', 'Tom'].map(label => ({ value: label, label }));
</script>
<style>
.example {
display: grid;
gap: 20px;
}
</style>
<div class="example">
<Select options={(options)} status="error" aria-label={("Select error")} placeholder={("Correct selection")} />
<Select options={(options)} status="warning" aria-label={("Warning Select")} defaultValue="Lucy" />
</div>
Empty issue
notFoundContent accepts text, number, null or Svelte snippet for an empty list.
<script lang="ts">
import { Select } from '@woodger/antd';
</script>
{#snippet empty()}<span
role="status"
>{("No matches. Change your request.")}</span>{/snippet}
<Select
options={([])}
showSearch
aria-label={("Empty search Select")}
notFoundContent={(empty)}
placeholder={("Start your search")}
/>
List container
getPopupContainer specifies the popup list container. The root Select is passed to getter after mount.
<script lang="ts">
import { Select } from '@woodger/antd';
let host = $state<HTMLDivElement>();
const options = ["First", "Second", "Third"].map(label => ({ value: label, label }));
</script>
<style>
.host {
position: relative;
padding: 16px;
border: 1px dashed var(--ant-color-border);
border-radius: 6px;
}
</style>
<div class="host" bind:this={host}>
<Select
options={(options)}
aria-label={("Select list container")}
getPopupContainer={trigger => host ?? trigger}
placeholder={("List inside this container")}
/>
</div>
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.
<script lang="ts">
import { RadioGroup, Select, type SelectProps } from '@woodger/antd';
const placements = ['topLeft', 'topRight', 'bottomLeft', 'bottomRight'];
const options = ['Button', 'Input', 'Select'].map(value => ({ value, label: value }));
let placement = $state<SelectProps['placement']>('bottomLeft');
</script>
<style>
.controls {
margin-bottom: 16px;
}
</style>
<div class="controls">
<RadioGroup
aria-label={("Select popup placement")}
options={placements}
bind:value={placement}
/>
</div>
<Select
aria-label={("Select with popup placement")}
{options}
{placement}
popupAlign={{ offset: [0, placement?.startsWith('top') ? -8 : 8] }}
transitionName="ant-slide-up"
placeholder={("Choose a component")}
/>
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.
<script lang="ts">
import { RadioGroup, Select } from '@woodger/antd';
const widths = [true, false, 120, 320].map(value => ({ value, label: String(value) }));
const options = [
{ value: 'button', label: 'Button' },
{ value: 'settings', label: "Component settings and localization" }
];
let width = $state<boolean | number>(true);
</script>
<style>
.controls { margin-bottom: 16px; }
.field {
width: 180px;
max-width: 100%;
}
</style>
<div class="controls">
<RadioGroup
aria-label={("Select popup width")}
options={widths}
bind:value={width}
/>
</div>
<div class="field">
<Select
aria-label={("Select with popup width settings")}
options={(options)}
popupMatchSelectWidth={width}
style="
width: 100%;
min-width: 0;
"
placeholder={("Choose a component")}
/>
</div>
Selected teams: 2.
Multiple selection in Form
The model stores an array of numeric identifiers. Form checks quantity, submits and resets selection.
<script lang="ts">
import { Button, Form, FormItem, Select, createForm, type SelectOption } from '@woodger/antd';
const teams: SelectOption<number>[] = [
{ value: 0, label: "Development" },
{ value: 1, label: "Design" },
{ value: 2, label: "Analytics" },
{ value: 3, label: "Support" },
{ value: 4, label: "Archive", disabled: true }
];
const form = createForm<{ teams: number[] }>({
initialValues: { teams: [0, 1] },
rules: ({
teams: [
{ required: true, message: "Select at least one command." },
{ max: 3, message: "Select no more than three teams." }
]
})
});
let result = $state('');
function finish(values: { teams: number[] }) {
const labels = values.teams.map(value => {
const team = teams.find(team => team.value === value);
return team?.label;
});
const selectedTeams = labels.join(', ');
result = ("Commands saved: " + String((selectedTeams)) + ".");
}
</script>
<style>
.example { max-width: 640px; }
.actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.selection {
margin: 16px 0 0;
color: var(--ant-color-text-tertiary);
font-size: 12px;
}
.result {
margin: 16px 0 0;
color: var(--ant-color-success);
}
</style>
<div class="example">
<Form {form} onFinish={finish}>
<FormItem name="teams" label={("Participant's teams")} help={("Select from one to three teams.")}>
<Select
mode="multiple"
options={(teams)}
value={form.values.teams}
onValueChange={(value) => {
form.setFieldValue('teams', value);
result = '';
}}
allowClear
placeholder={("Select commands")}
/>
</FormItem>
<div
class="actions"
><Button
type="primary"
htmlType="submit"
loading={form.isSubmitting}
>{("Save commands")}</Button><Button
htmlType="reset"
onclick={() => { result = ''; }}
>{("Reset commands")}</Button></div>
</Form>
<p class="selection" role="status" aria-label={("Selected commands")}>{("Selected teams: ")}{(form.values.teams.length)}.</p>
{#if result}<p class="result" role="status">{result}</p>{/if}
</div>
Separators and input parsing
Separator array and whole string function; native parsing removes whitespace around the edges.
<script lang="ts">
import { Select } from '@woodger/antd';
let automatic = $state<string[]>([]);
let custom = $state<string[]>([]);
function tokenize(input: string) {
return /[,;\n]/.test(input)
? input.split(/[,;\n]/).map(value => value.trim()).filter(Boolean)
: [];
}
</script>
<style>
.example {
display: grid;
gap: 12px;
}
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<Select
mode="tags"
bind:value={automatic}
tokenSeparators={[',', ';', '\n']}
aria-label={("Tag separators")}
placeholder={("Svelte,TypeScript")}
allowClear
/>
<output aria-label={("Tags with delimiters")}>{JSON.stringify(automatic)}</output>
<Select mode="tags" bind:value={custom} tokenSeparators={tokenize}
aria-label={("Own tag parsing")} placeholder={("Spaces around the edges are removed")} allowClear />
<output
aria-label={("Tags after own analysis")}
>{JSON.stringify(custom)}</output>
</div>
Selection limitation
maxCount=2 limits new values; the selected option can be deselected.
<script lang="ts">
import { Select } from '@woodger/antd';
const options = ["Development", "Design", "Analytics", "Support"]
.map((label, value) => ({ value, label }));
let values = $state<number[]>([0]);
</script>
<style>
output {
display: block;
margin-top: 12px;
overflow-wrap: anywhere;
}
</style>
<Select mode="multiple" options={(options)} bind:value={values} maxCount={2}
aria-label={("No more than two commands")} allowClear />
<output aria-label={("Restricted commands")}>{JSON.stringify(values)}{(" maximum 2")}</output>
Text and number of tags
Truncate captions, maxTagCount, and summary tag snippet retain full values.
<script lang="ts">
import { Checkbox, Select, type SelectOmittedTag } from '@woodger/antd';
const options = ['Svelte', 'TypeScript', 'Accessibility', 'Internationalization']
.map(label => ({ value: label, label }));
let values = $state(options.map(option => option.value));
let all = $state(false);
</script>
<style>
.example {
display: grid;
gap: 12px;
}
output { overflow-wrap: anywhere; }
</style>
{#snippet omitted(tags: SelectOmittedTag<string>[])}
<span title={tags.map(tag => tag.label).join(', ')}>{("More ")}{(tags.length)}</span>
{/snippet}
<div class="example">
<Checkbox bind:checked={all}>{("Show all tags")}</Checkbox>
<Select
mode="multiple"
options={(options)}
bind:value={values}
maxTagCount={all ? undefined : 2}
maxTagTextLength={8}
maxTagPlaceholder={omitted}
aria-label={("Summary Tag Select")}
/>
<output aria-label={("Values behind summary tag")}>{JSON.stringify(values)}</output>
</div>
Large list
100000 options with virtual scrolling. scrollTo, focus and blur through SelectRef.
<script lang="ts">
import { tick } from 'svelte';
import { Button, Select, type SelectRef } from '@woodger/antd';
const options = Array.from({ length: 100000 }, (_, index) => {
const value = `${index.toString(36)}${index}`;
return { value, label: value, disabled: index === 10 };
});
let control = $state<SelectRef>();
let value = $state(['a10', 'c12']);
let opened = $state(false);
async function showLastOption() {
opened = true;
await tick();
control?.scrollTo({ index: options.length - 1, align: 'bottom' });
control?.focus();
}
</script>
<style>
.example {
display: grid;
gap: 16px;
min-width: 0;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
output {
color: var(--ant-color-text-secondary);
overflow-wrap: anywhere;
}
</style>
<div class="example">
<div>{("Options: ")}{options.length}</div>
<Select
{options}
mode="multiple"
virtual
bind:this={control}
bind:value
bind:open={opened}
aria-label={("Large Select list")}
placeholder={("Select options")}
style="width:100%"
/>
<div class="actions">
<Button onclick={showLastOption}>{("Go to last option")}</Button>
<Button onclick={() => control?.focus()}>{("Focus Select")}</Button>
<Button onclick={() => control?.blur()}>{("Blur Select")}</Button>
</div>
<output aria-label={("Large list selection")}>
{JSON.stringify(value)}
</output>
</div>
<script lang="ts">
import { Select, Tag, type SelectTagInfo } from '@woodger/antd';
const options = ['Svelte', 'TypeScript', 'CSS'].map(label => ({ value: label, label }));
let values = $state(options.map(option => option.value));
</script>
<style>
output {
display: block;
margin-top: 12px;
overflow-wrap: anywhere;
}
</style>
{#snippet tag(info: SelectTagInfo<string>)}
<Tag color={info.isMaxTag ? undefined : 'green'} closable={info.closable}
disabled={info.disabled} onClose={info.onClose}
closeLabel={info.isMaxTag ? undefined : `Delete your tag ${info.value}`}
style="margin-inline-end: 4px"
onmousedown={event => {
event.preventDefault();
event.stopPropagation();
}}>{@render info.label()}</Tag>
{/snippet}
<Select mode="multiple" options={(options)} bind:value={values} maxTagCount={2}
tagRender={tag} aria-label={("Custom Tags Select")} />
<output aria-label={("Own tag values")}>{JSON.stringify(values)}</output>
Description Items
optionRender gets source data and index; The label of the selected value remains text.
<script lang="ts">
import { Select, type SelectFlattenOption } from '@woodger/antd';
interface Technology {
value: string;
label: string;
description: string;
}
const options: Technology[] = [
{ value: 'svelte', label: 'Svelte', description: "Reactive interface" },
{ value: 'typescript', label: 'TypeScript', description: "Type checking" },
{ value: 'css', label: 'CSS', description: "Page design" }
];
let value = $state<string>();
</script>
<style>
.option {
display: grid;
gap: 2px;
}
.description {
font-size: 12px;
color: var(--ant-color-text-secondary);
}
output {
display: block;
margin-top: 12px;
overflow-wrap: anywhere;
}
</style>
{#snippet optionContent(
option: SelectFlattenOption<string, Technology>,
info: { index: number }
)}
<span class="option">
<strong>{(info.index + 1)}. {(option.data.label)}</strong>
<span class="description">{(option.data.description)}</span>
</span>
{/snippet}
<Select
options={(options)}
bind:value
optionRender={optionContent}
showSearch
aria-label={("Description Items")}
placeholder={("Select technology")}
/>
<output aria-label={("Item value with description")}>{(value
?? ("Not selected"))}</output>
Opening control
bind:open and open/onOpenChange: The owner accepts or denies the request. An empty output retains the numeric content of 0.
<script lang="ts">
import { Button, Checkbox, Select } from '@woodger/antd';
const options = ["Alpha", "Beta", "Gamma"].map(label => ({ value: label, label }));
let boundOpen = $state(false);
let boundValue = $state<string>();
let boundRequests = $state<boolean[]>([]);
let ownerOpen = $state(false);
let accept = $state(true);
let ownerRequests = $state<boolean[]>([]);
function requestOpen(next: boolean) {
ownerRequests = [...ownerRequests, next];
if (accept) ownerOpen = next;
}
</script>
<style>
.example {
display: grid;
gap: 12px;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Button
onclick={() => { boundOpen = true; }}
>{("Open related list")}</Button>
<Button
onclick={() => { boundOpen = false; }}
>{("Close linked list")}</Button>
</div>
<Select options={(options)} bind:open={boundOpen} bind:value={boundValue}
onOpenChange={next => { boundRequests = [...boundRequests, next]; }}
aria-label={("Linked Visibility Select")} placeholder={("Select value")} />
<output aria-label={("Related Opening Select")}>
{(boundOpen ? "Open" : "Closed")}{("; requests: ")}{JSON
.stringify(boundRequests)}
</output>
<Checkbox bind:checked={accept}>{("Accept list requests")}</Checkbox>
<Select options={(options)} open={ownerOpen} onOpenChange={requestOpen} showSearch
notFoundContent={(0)} aria-label={("Owner's Select visibility")} />
<output aria-label={("Opening Select from the owner")}>
{(ownerOpen ? "Open" : "Closed")}{("; requests: ")}{JSON
.stringify(ownerRequests)}
</output>
</div>
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.
<script lang="ts">
import { Checkbox, Select } from '@woodger/antd';
const options = ["First", "Second"].map(label => ({ value: label, label }));
let initialOpen = $state(true);
let disabled = $state(false);
let requests = $state<boolean[]>([]);
</script>
<style>
.example {
display: grid;
gap: 12px;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
output { overflow-wrap: anywhere; }
p { margin: 0; }
</style>
<div class="example">
<Select options={(options)} defaultOpen={initialOpen} {disabled}
onOpenChange={next => { requests = [...requests, next]; }}
aria-label={("Initial Visibility Select")} placeholder={("Opens after mount")} />
<div class="controls">
<Checkbox bind:checked={initialOpen}>{("Initial opening")}</Checkbox>
<Checkbox bind:checked={disabled}>{("Disable Select")}</Checkbox>
</div>
<output
aria-label={("Initial Select requests")}
>{JSON.stringify(requests)}</output>
<p>{("DefaultOpen is in effect on creation. Changing it later does not re-open the list.")}</p>
</div>
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.
<script lang="ts">
import { Checkbox, ConfigProvider, Select } from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
const prefix = $derived(custom ? 'suite' : 'ant');
const localPrefix = $derived(local ? 'project-select' : '');
let value = $state<string[]>(['docs']);
</script>
<style>
.example,
.prefix-stage {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("General prefix Select suite")}</Checkbox>
<Checkbox bind:checked={local}>{("Local prefix Select")}</Checkbox>
</div>
<ConfigProvider prefixCls={prefix} theme={{ cssVar: { prefix: 'select-theme' } }}>
<div class="prefix-stage">
<Select
prefixCls={localPrefix}
mode="multiple"
bind:value
showSearch
aria-label={("Select with prefix")}
style="width:100%"
options={([
{ value: 'docs', label: "Documentation" }, { value: 'examples', label: "Examples" }
])}
/>
<output
aria-label={("Select with prefix")}
>{JSON.stringify(value)}</output>
</div>
</ConfigProvider>
<output
aria-label={("CSS prefix Select")}
>{("General: ")}{prefix}{("; local: ")}{(localPrefix
|| ("from the provider"))}</output>
<p>
{("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.")}
</p>
</div>
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.
| ant.design theme | Condition | Explanation |
|---|---|---|
| Basic Usage | Available· Example | Single selection, disabled, loading and clearing. |
| Select with search field | Available· Example | Search by label. |
| Custom Search | Available· Example | Predicate filterOption. |
| Multi field search | Available· Example | showSearch.optionFilterProp searches for several fields using OR. |
| multiple selection | Available· Example | Array of selected values. |
| Sizes | Available· Example | Three sizes from the public API. |
| Custom dropdown options | Available· Example | optionRender receives the source record and an index that includes group headings. |
| Search with sort | Available· Example | showSearch.filterSort sorts the filtering result without changing options. |
| Tags | Available· Example | Free string values; options is optional. |
| Option Group | Available· Example | One level of groups, search, and navigation that skips disabled options. |
| coordinate | In the application· Example | Communication of two Selects through the application model. |
| Get value of selected item | Available· Example | labelInValue keeps value and label in the model and selection events. |
| Automatic tokenization | Available· Example | Array of tokenSeparators for multiple/tags. |
| Custom tokenization | Available· Example | The tokenSeparators function receives the entire input string. |
| Search and Select Users | Available· Example | Guided search and in-app download options. |
| Prefix and Suffix | Available· Example | prefix adds content before the field; suffix replaces the trailing area according to its state. |
| Custom dropdown | Available· Example | popupRender extends the original menu through a Svelte snippet. |
| Hide Already Selected | Available· Example | The selected tag keeps its label and onDeselect receives the original record after removal from options. |
| Variants | Available· Example | outlined, filled, borderless and underlined for single/multiple, including inheritance from context. |
| Custom Tag Render | Available· Example | Snippet receives a label, typed value and onClose; The summary tag is not removed. |
| Custom Selected Label Render | Available· Example | A pure labelRender function returns text or a Svelte snippet. |
| Responsive maxTagCount | Available· Example | The field width determines the visible tags; hidden meanings remain in the model and form. |
| Big Data | Available· Example | 100000 options with measured virtual scrolling and scrollTo navigation. |
| Status | Available· Example | error and warning. |
| Placement | Available· Example | Four physical popup corners, adjusted for available space. |
| Max Count | Available· Example | Limiting new values via maxCount in multiple/tags. |
| Custom semantic dom styling | Available· Example | classNames/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.
| Property | Description | Type | Default |
|---|---|---|---|
showAction | The focus value opens the list when the editor receives focus. | readonly ("focus" | "click")[] | — |
virtual | Enables list windowing; ConfigProvider.virtual applies without a local prop. | boolean | ConfigProvider / true |
listHeight | Maximum inner viewport height in px; 0 removes the limit. | number | 256 |
listItemHeight | Estimated row height before measurement; 0 disables windowing. | number | token.controlHeight |
showScrollBar | Optional displays the scrollbar during scrolling and hides it after 3 seconds. | boolean | 'optional' | optional |
labelInValue | The model and events pass { value, label }; multiple/tags use arrays of objects. | boolean | false |
optionLabelProp | The raw record field for the selected label. An explicit owner label takes priority. | string | fieldNames.label |
labelRender | A pure display function, including Snippet content. null/undefined falls back to the raw value. | (info: SelectLabelRenderInfo) => RenderEmptyContent | undefined |
popupRender | A pure function receives the original menu; it also runs during SSR and while closed. | SelectPopupRender | undefined |
prefix | Content before the editor. Falsy scalars, including 0, create no element. | RenderEmptyContent | undefined |
rootClassName | A shared class for the control and popup; the existing class remains on the outer Select container. | string | undefined |
classNames | Classes for control and popup parts; local classes combine with ConfigProvider.select. | SelectClassNames | ((info: SelectSemanticInfo) => SelectClassNames) | undefined |
styles | Part styles. A local popup leaf replaces the corresponding provider leaf entirely. | SelectStyles | ((info: SelectSemanticInfo) => SelectStyles) | undefined |
style | A CSS object styles the control; a CSS string retains outer-container styling. | SelectStyle | undefined |
defaultActiveFirstOption | Activates the first available option on opening and search changes. | boolean | true |
onActive | Reports the active option or null; selection is a separate event. | (value: Value | string | null) => void | — |
nativeElement | The root div or the registered components.root element after mount. | RootElement | HTMLDivElement | undefined | undefined |
inputElement | The native input or the registered components.input element after mount. | EditorElement | HTMLInputElement | undefined | undefined |
components | Input 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 |
suffix | Replaces 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 |
loadingIcon | Loading glyph in the standard suffix when loading=true. | RenderEmptyContent | From context |
menuItemSelectedIcon | Option icon; a pure function receives value, disabled and isSelected. | SelectRenderNode<SelectMenuItemIconInfo<Value>> | From context |
removeIcon | Removal icon for a standard multiple/tags tag. Does not replace the button in tagRender. | SelectRenderNode<undefined> | From context |
onInputKeyDown | Editor keyboard event; preventDefault does not automatically cancel selection or tokenSeparators. | (event: KeyboardEvent) => void | — |
prefixCls | Full 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. | string | ConfigProvider.prefixCls + "-select" |
variant | Local variant → closest Form.variant → ConfigProvider.select.variant → general ConfigProvider.variant → outlined. | Variant | From context / outlined |
options | Source records and one level of groups. fieldNames maps value/label/options fields. | readonly OptionType[] | [] |
fieldNames | Source field names for the value, label, children, and group heading. | SelectFieldNames | value / label / options; groupLabel = label |
value | bind:value links a value or array; labelInValue enables objects. null clears selection. | SelectValueModel<Value, Mode, LabelInValue> | null | undefined |
defaultValue | The initial model depends on mode and labelInValue; native reset restores it. | Value | SelectLabelValue<Value> | readonly (Value | SelectLabelValue<Value>)[] | null | undefined |
mode | Default single selection; multiple selects ready-made options, tags creates strings. | multiple | tags | undefined |
showSearch | Enables search. The object configures the search string, callback and local filtering. | boolean | SelectSearchConfig<Value, OptionType> | multiple/tags: true; single: false |
allowClear | Clearing: single → undefined, multiple/tags → []. The object sets clearIcon and label; the application translates the accessible name. | boolean | SelectAllowClear | ConfigProvider.select / false |
loading | Shows indicator and aria-busy; request management remains in the application. | boolean | undefined |
notFoundContent | General contents, including boolean and readonly arrays. null/false/empty string hides empty popup, 0 is visible; undefined inherits renderEmpty. | RenderEmptyContent | From context |
size | large, medium or small; the usual height depends on the theme. | ComponentSize | From context |
status | Visual condition; error adds aria-invalid. | error | warning | From FormItem |
disabled | Blocks selection and excludes the native field from submission. | boolean | From context |
placement | Preferred popup placement. The provider popupOverflow sets the overflow calculation region; getPopupContainer selects the DOM container. | bottomLeft | bottomRight | topLeft | topRight | bottomLeft; in RTL bottomRight |
popupAlign | Anchor points, offsets, and overflow adjustment for the selected popup position. | SelectPopupAlign | — |
builtinPlacements | Map of popup positions for placement values. | Readonly<Record<string, SelectPopupAlign>> | Built-in map |
transitionName | Name of the popup CSS animation. | string | Component animation |
popupMatchSelectWidth | true 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 | number | ConfigProvider / true |
getPopupContainer | Selects 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 | ShadowRoot | From context, otherwise the component parent |
onPopupScroll | Native scroll event from the inner viewport; currentTarget and this refer to its div. | HTMLAttributes<HTMLDivElement>[onscroll] | — |
onValueChange | Receives the model after selection and clearing; onChange also provides record data. | (value: SelectValueModel<Value, Mode, LabelInValue> | undefined) => void | — |
onChange | Called 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"] | — |
onSelect | Every option selection, including repeated single selection without changing value. | SelectProps<Value, Mode, OptionType, LabelInValue>["onSelect"] | — |
onDeselect | Removal of an individual value in multiple/tags. Clearing all values does not call it. | SelectProps<Value, Mode, OptionType, LabelInValue>["onDeselect"] | — |
onClear | User clearing before onChange; single produces undefined, multiple/tags produces []. | () => void | — |
onOpenChange | Request to change visibility. When open, the owner accepts or rejects the request; initial and external updates do not trigger a callback. | (open: boolean) => void | — |
open | Managed visibility, including bind:open. Takes precedence over defaultOpen; The SSR remains closed. | boolean | undefined |
defaultOpen | Initial uncontrolled visibility after mount. Subsequent prop changes do not re-open the list. | boolean | false |
class | Class of the standard field’s outer container. | string | — |
tokenSeparators | An array of delimiters or a function of the entire string. multiple accepts ready-made options; tags creates strings. | SelectTokenSeparators | — |
maxCount | Maximum of new selected multiple/tags values. An array already passed is not truncated. | number | no limit |
maxTagTextLength | Limits the visible tag text to UTF-16, preserving the full label and value; surrogate pair is not broken. | number | no limit |
maxTagCount | Limits display only. responsive measures the width in the browser; SSR shows all values. | number | responsive | all tags |
maxTagPlaceholder | Scalar or Snippet with hidden SelectOmittedTag. null/undefined select default; false leaves an empty summary. | SelectTagPlaceholder<Value> | + N ... |
tagRender | Contents of regular and summary tags multiple/tags. label - Snippet; summary does not have value, index and onClose. | Snippet<[SelectTagInfo<Value>]> | — |
optionRender | Data contains the source record, label has type unknown, and groupOption identifies group children. | Snippet<[SelectFlattenOption<Value, OptionType>, { index: number }]> | — |
showSearch
| Property | Description | Type | Default |
|---|---|---|---|
showSearch.searchIcon | Search icon in the standard suffix of an open field. | RenderEmptyContent | From context |
showSearch.searchValue | Managed search string. The options list and selected values are updated independently. | string | undefined |
showSearch.onSearch | Gets the custom search string; The application loads the data. | (search: string) => void | — |
showSearch.filterOption | Local filtering or predicate (search, option). For remote search, set it to false. | boolean | predicate | true |
showSearch.optionFilterProp | Fields of the original option, combined via OR. The filterOption predicate takes precedence. | string | readonly string[] | single/multiple: label; tags: value |
showSearch.filterSort | Sorts the filtered list, including synthetic tags, preserving the owner's options. | (a, b, { searchValue }) => number | — |
showSearch.autoClearSearchValue | Clear local search when selected in multiple/tags. The managed searchValue updates the owner. | boolean | true |
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.
| Method | Type | Application |
|---|---|---|
focus | (options?: FocusOptions) => void | Focuses the editor. |
blur | () => void | Blurs the editor. |
scrollTo | (config?: SelectScrollConfig | null) => void | Scrolls 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>
| Token | Purpose |
|---|---|
activeBorderColor | Frame color when focused. |
activeOutlineColor | Focus outline color. |
clearBg | Clean button background. |
hoverBorderColor | Hover frame. |
multipleItemBg | Background of the selected tag. |
multipleItemBorderColor | Frame of the selected tag. |
multipleItemBorderColorDisabled | Frame of an inaccessible tag. |
multipleItemColorDisabled | Text of an inaccessible tag. |
multipleItemHeight | Normal tag height. |
multipleItemHeightLG | Large tag height. |
multipleItemHeightSM | Small tag height. |
multipleSelectorBgDisabled | Background of inaccessible multiple Select. |
optionActiveBg | Background of the active variant. |
optionFontSize | Option text size. |
optionHeight | Height option. |
optionLineHeight | Variant row height. |
optionPadding | Option indents. |
optionSelectedBg | Background of the selected option. |
optionSelectedColor | Text of the selected option. |
optionSelectedFontWeight | Text thickness of the selected option. |
selectorBg | Field background. |
showArrowPaddingInlineEnd | Place for arrow. |
singleItemHeightLG | Height of a large single value. |
zIndexPopup | List layer. |
Common tokens of the current topic
Values are read through theme.useToken() and change along with the settings in the header.
| Token | Purpose | Current value |
|---|---|---|
colorBgContainer | Background of a regular field. | #ffffff |
colorBgContainerDisabled | Background of the inaccessible icon. | rgba(0,0,0,0.04) |
colorBgElevated | Dropdown background. | #ffffff |
colorBorder | Frame color. | #d9d9d9 |
colorBorderDisabled | Frame of an inaccessible element. | #d9d9d9 |
colorError | Primary color of the error. | #ff4d4f |
colorErrorAffix | Color of additions when there is an error. | #ff4d4f |
colorErrorBg | Error background. | #fff2f0 |
colorErrorBgHover | Hover error background. | #fff1f0 |
colorErrorBorderHover | Hover error frame. | #ffa39e |
colorErrorOutline | Error circuit. | rgba(255,38,5,0.06) |
colorErrorText | Error text. | #ff4d4f |
colorFillQuaternary | Weak filling. | rgba(0,0,0,0.02) |
colorFillSecondary | Secondary filling. | rgba(0,0,0,0.06) |
colorFillTertiary | Tertiary fill. | rgba(0,0,0,0.04) |
colorIcon | Icon color. | rgba(0,0,0,0.45) |
colorIconHover | Color of icons when hovering. | rgba(0,0,0,0.88) |
colorPrimary | Primary color of interactive states. | #2f54eb |
colorPrimaryBorder | Light outline of the main color. | #adc6ff |
colorSplit | Separator color. | rgba(5,5,5,0.06) |
colorText | Label color. | rgba(0,0,0,0.88) |
colorTextDescription | Description color. | rgba(0,0,0,0.45) |
colorTextDisabled | Color of unavailable label. | rgba(0,0,0,0.25) |
colorTextPlaceholder | Input prompt color. | rgba(0,0,0,0.25) |
colorTextQuaternary | Secondary text color. | rgba(0,0,0,0.25) |
colorWarning | Primary warning color. | #faad14 |
colorWarningAffix | Color warning additions. | #faad14 |
colorWarningBg | Warning background. | #fffbe6 |
colorWarningBgHover | Hover alert background. | #fff1b8 |
colorWarningHover | Hover alert color. | #ffd666 |
colorWarningOutline | Warning circuit. | rgba(255,215,5,0.1) |
borderRadius | Normal rounding. | 6 |
borderRadiusLG | Large rounding. | 8 |
borderRadiusSM | Icon rounding. | 4 |
borderRadiusXS | Minimum rounding. | 2 |
boxShadowSecondary | Drop-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)
|
controlHeight | Normal field height. | 32 |
controlHeightLG | Large field height. | 40 |
controlHeightSM | Height of the small field. | 24 |
controlItemBgActiveHover | Background of the selected item when hovering. | #d6e4ff |
controlOutlineWidth | Thickness of the element outline. | 2 |
controlPaddingHorizontal | Horizontal padding of the element. | 12 |
fontFamily | Font 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' |
fontSize | Basic text size. | 14 |
fontSizeIcon | Icon size. | 12 |
fontSizeLG | Large text size. | 16 |
fontSizeSM | Small text size. | 12 |
lineHeight | Label line height. | 1.5714285714285714 |
lineHeightLG | Large line height. | 1.5 |
lineType | Frame line type. | solid |
lineWidth | Frame thickness. | 1 |
marginXS | Small external indent. | 8 |
motionDurationMid | Duration of main transitions. | 0.2s |
motionDurationSlow | Duration of slow transitions. | 0.3s |
motionEaseInOut | Smooth transition curve. | cubic-bezier(0.645, 0.045, 0.355, 1) |
motionEaseInOutCirc | Transition curve. | cubic-bezier(0.78, 0.14, 0.15, 0.86) |
motionEaseInQuint | Transition acceleration curve. | cubic-bezier(0.755, 0.05, 0.855, 0.06) |
motionEaseOutCirc | Transition deceleration curve. | cubic-bezier(0.08, 0.82, 0.17, 1) |
motionEaseOutQuint | Transition deceleration curve. | cubic-bezier(0.23, 1, 0.32, 1) |
paddingSM | Small internal indent. | 12 |
paddingXS | Indentation of the label from the icon. | 8 |
paddingXXS | Minimum 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.