Select is a control that provides a list of options that a user can select.
import {Select} from '@gravity-ui/uikit';
[!NOTE] In v8 the options are drawn by the new list. What changed for a consumer is collected in the migration guide.
§Options
Options to select.
§Defining options
You can define options as an array of objects or as the children of a component. The first approach is useful for cases where options require complex preparation and, possibly, memorization. The second one is convenient when there are few options, and their configuration does not require complex calculations.
In a React Server Component Select.Option and Select.OptionGroup are not reachable: use the named
SelectOption and SelectOptionGroup instead. Their props types are SelectOptionProps and
SelectOptionGroupProps.
§Flat list
import {Flex, Select} from '@gravity-ui/uikit'; const options = [ {value: 'val_1', content: 'Value 1'}, {value: 'val_2', content: 'Value 2'}, {value: 'val_3', content: 'Value 3'}, {value: 'val_4', content: 'Value 4'}, ]; export default function () { return ( <> <Flex gap="spacing-1" alignItems="center"> Array of objects <Select placeholder="value" options={options} /> </Flex> <Flex gap="spacing-1" alignItems="center"> Child nodes <Select placeholder="value"> <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> </Flex> </> ); }
§The text of an option
The text of an option is what the trigger shows for a selected option, what the filter matches and
what the search by the first letters looks up. By default it is the content of the option when that
is a string or a number, its children when those are, and its value otherwise — so an option that renders anything but a plain string needs
getOptionText, or it will be searched and named by its value.
useSelectOptions takes the same property: pass it there as well when the options are filtered
outside of the component. Define the function outside the component or memoize it — it takes part in
the memoization of the list, and a new function on every render rebuilds the rows.
getOptionText replaces the text property of an option, which is gone: the text of an option is
asked for rather than stored, so one function covers every option instead of a field repeated on
each of them.
The value of an option identifies its row, so the values have to be unique across the whole list,
groups included (for a non-string value — its key). The DOM id of the row is
derived from it, and that id is what aria-activedescendant of the trigger points at — read it from
there rather than building it by hand: the escaping of a value belongs to the list and is not a
contract.
§Grouped list
A group header is a caption rather than an option: it carries role="presentation", stays out of
the keyboard walk and out of the count of role="option" rows, and describes the options under it
through aria-describedby. A group whose label is empty draws a separating line instead of a
header — as the first row of the list it has nothing to separate and takes no space at all. That is
the default drawing of a group: renderOptionGroup and getOptionGroupHeight are asked first and
render and measure whatever they like, empty label or not.
import {Flex, Select} from '@gravity-ui/uikit'; const groupedOptions = [ { label: 'Group 1', options: [ {value: 'val_1', content: 'Value 1'}, {value: 'val_2', content: 'Value 2'}, ], }, { label: 'Group 2', options: [ {value: 'val_3', content: 'Value 3'}, {value: 'val_4', content: 'Value 4'}, ], }, ]; export default function () { return ( <> <Flex gap="spacing-1" alignItems="center"> Array of objects <Select placeholder="value" options={groupedOptions} /> </Flex> <Flex gap="spacing-1" alignItems="center"> Child nodes <Select placeholder="value"> <Select.OptionGroup label="Group 1"> <Select.Option value="val_1" content="Value 1" /> <Select.Option value="val_2" content="Value 2" /> </Select.OptionGroup> <Select.OptionGroup label="Group 2"> <Select.Option value="val_3" content="Value 3" /> <Select.Option value="val_4" content="Value 4" /> </Select.OptionGroup> </Select> </Flex> </> ); }
§Storing data in options
You can define and store unique data in each option by using the option.data property. This can be useful when you need to enrich the data when using the onUpdate callback or, for example, when drawing your options with renderOption.
§Non-string values
The value of an option can be of any type: the type of value, defaultValue and onUpdate follows
the options. The Select knows a value by a string key — the id of its row, the field of a form and
the comparison of two values all use it. A string is its own key, another primitive is turned into
one with String(), and an object needs getValueKey. Values with equal keys are one value: an
object from a new response selects the option it matches. Define getValueKey outside the component
or memoize it, as getOptionText.
An object value has no text of its own: give the option a string content or pass getOptionText.
A Select.Option child takes a string unless its type is named: <Select.Option<unknown, number> value={1}>; the Select itself takes the type from value or a typed onUpdate={(value: number[]) => …}. A selected value with no option is shown by its key; keep its option in options or render it
with renderSelectedOptions. A form submits keys, not values. In a union type 1
and "1" share a key and are one value.
§Nullable values
'', null and undefined mean no value unless an option declares them. Without an option such a
value has no text, clear button or count, a form sends it as '', while value and onUpdate keep
it as is. 0 and false are always values.
§Selecting multiple options
To enable multiple selection, use the multiple property. Its default value is false.
import {Select} from '@gravity-ui/uikit'; export default function () { return ( <Select multiple placeholder="values"> <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> ); }
Shift+click, Shift+↑/↓ and Shift+Space select a range of options, from the option chosen last to the target.
§Counter
You can add a counter of the selected items to the component using the hasCounter property.
import {Select} from '@gravity-ui/uikit'; export default function () { return ( <Select multiple hasCounter placeholder="values"> <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> ); }
§Filtering options
To enable filter section, use the filterable property. Its default value is false.
import {Select} from '@gravity-ui/uikit'; export default function () { return ( <Select filterable placeholder="Filterable"> <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> ); }
§The search by the first letters
With the popup open and no filter in the way, the character keys look up an option: the list moves the activity to the first option whose text starts with what was typed, the buffer resets a second after the last key, and repeating one character cycles through the options that start with it. A space belongs to the query while it is being typed, so a label with a space in it is reachable — and it selects nothing until the buffer is empty again. A character the list took for its search does not reach the hotkeys of the application around it.
In a filterable Select the keys go into the filter instead: typing there is filtering.
§Size
To manage the default control and option size, use the size property. Its default size is m.
import {Select} from '@gravity-ui/uikit'; export default function () { return ( <> <Select size="s" placeholder="S Size"> <Select.Option value="val_1">Value 1</Select.Option> </Select> <Select size="m" placeholder="M Size"> <Select.Option value="val_1">Value 1</Select.Option> </Select> <Select size="l" placeholder="L Size"> <Select.Option value="val_1">Value 1</Select.Option> </Select> <Select size="xl" placeholder="XL Size"> <Select.Option value="val_1">Value 1</Select.Option> </Select> </> ); }
§Control width
By default, the control width stretches to match the width of the content of the selected options. You can manage it by using the width property:
'max': Stretches to the full width of the parent.
number: Applies width in pixels.
import {Select, SelectProps} from '@gravity-ui/uikit'; import {type CSSProperties} from 'react'; const containerStyle: CSSProperties = { width: 150, border: '2px dashed gray', textAlign: 'center', }; function SelectExample(props: SelectProps) { return ( <Select {...props}> <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> ); } export default function () { return ( <> <div style={containerStyle}> <h4>Default</h4> <SelectExample multiple /> </div> <div style={containerStyle}> <h4>Max</h4> <SelectExample width="max" multiple /> </div> <div style={containerStyle}> <h4>In pixels</h4> <SelectExample width={110} multiple /> </div> </> ); }
§Popup width
You can manage the popup width with the popupWidth property. The available values are:
'fit': Apply control width.
number: Apply width in pixels.
Points to note about the default behavior:
-
The popup width is equal to the width of the widest option, but not wider than
90vw. This does not apply to a virtualizedSelect. -
Narrow options are stretched to fit the width of the control.
import {Box, Select, SelectProps} from '@gravity-ui/uikit'; import {type CSSProperties} from 'react'; const containerStyle: CSSProperties = { width: 200, border: '2px dashed gray', textAlign: 'center', }; function ShortValueSelect(props: SelectProps) { return ( <Select placeholder="Short value" {...props}> <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> ); } function LongValueSelect(props: SelectProps) { return ( <Select placeholder="Long value" {...props}> <Select.Option value="val_1">Loooooooooooooooooooong Value 1</Select.Option> <Select.Option value="val_2">Loooooooooooooooooooong Value 2</Select.Option> <Select.Option value="val_3">Loooooooooooooooooooong Value 3</Select.Option> <Select.Option value="val_4">Loooooooooooooooooooong Value 4</Select.Option> </Select> ); } export default function () { return ( <> <div style={containerStyle}> <h4>Default</h4> <Box marginBlock="spacing-3"> <ShortValueSelect /> </Box> <Box marginBlock="spacing-3"> <LongValueSelect /> </Box> </div> <div style={containerStyle}> <h4>Fit</h4> <Box marginBlock="spacing-3"> <ShortValueSelect popupWidth="fit" /> </Box> <Box marginBlock="spacing-3"> <LongValueSelect popupWidth="fit" /> </Box> </div> <div style={containerStyle}> <h4>In pixels</h4> <Box marginBlock="spacing-3"> <ShortValueSelect popupWidth={80} /> </Box> <Box marginBlock="spacing-3"> <LongValueSelect popupWidth={80} /> </Box> </div> </> ); }
§Virtualized list
A long list of options is rendered row by row unless you ask for otherwise: every option is a DOM row. To render only the visible ones, wrap the Select in ListVirtualizer from the @gravity-ui/uikit/virtualizer entry point — the wrapper needs no configuration, and the popup keeps working through the portal. A couple of hundred options is where it starts to pay off; above 150 the Select says so in a development warning.
The entry point needs @tanstack/react-virtual: it is an optional peer dependency of the package and has to be installed alongside it.
import {Select} from '@gravity-ui/uikit';
import {ListVirtualizer} from '@gravity-ui/uikit/virtualizer';
<ListVirtualizer>
<Select options={thousandsOfOptions} />
</ListVirtualizer>;
The wrapper does not have to stand next to the Select: one wrapper with minItemsCount at the root of the app covers every Select below it. A Select of fewer options renders as if there were no wrapper — every option a DOM row, the popup as wide as the widest option. The Select counts all of its options, without the group headers and without the filter, so typing does not switch the list.
import {Provider} from '@gravity-ui/uikit';
import {ListVirtualizer} from '@gravity-ui/uikit/virtualizer';
<Provider theme="light">
<ListVirtualizer minItemsCount={50}>
<App />
</ListVirtualizer>
</Provider>;
To change the settings for one Select, put a second wrapper right around it. It changes only what it is given and takes the rest from the one at the root: overscan={20} keeps the threshold, minItemsCount={0} virtualizes that Select whatever the number of its options, and minItemsCount={Infinity} keeps it plain.
import {Select} from '@gravity-ui/uikit';
import {ListVirtualizer} from '@gravity-ui/uikit/virtualizer';
// Under the wrapper at the root: this Select is virtualized whatever the number of its options
<ListVirtualizer minItemsCount={0}>
<Select options={options} />
</ListVirtualizer>;
The code of the virtualizer is a chunk of its own, and it is not loaded for the shorter Selects. A Select that is going to be virtualized starts loading it on mount; a popup opened before it arrives shows its first options until the window takes over, and scrolls to the selected one then.
Things to keep in mind about a virtualized Select:
-
The popup width no longer gets adjusted to the length of the longest option.
-
The minimum width of the popup is equal to the width of the control, or
100pxif the control is shorter. -
The height of a row before it is rendered is taken from getOptionHeight and the
sizeof theSelect; theestimateItemSizeof the wrapper is not used, since the type of an option row does not leave theSelect— passing it writes a warning in development. Themeasureandoverscanproperties of the wrapper work as described for theList. -
A popup rendered on the server gets its first options instead of the window — there is no viewport to measure it against — and the window takes over after hydration.
-
The wrapper covers the list of this
Select, the one renderPopup puts on the page included. A list inside a row of it, or aSelectplaced in such a row, renders every row of its own instead: the virtualization of a list does not reach what its rows draw. -
Define
getOptionHeightandrenderOptionoutside the component or memoize them: a new function on every render makes the virtualizer start its measurements over and the rows re-render.
import {Box, Select} from '@gravity-ui/uikit'; import {ListVirtualizer} from '@gravity-ui/uikit/virtualizer'; import {type CSSProperties} from 'react'; const containerStyle: CSSProperties = { width: 200, border: '2px dashed gray', textAlign: 'center', }; const shortOptions = Array.from({length: 1000}, (_, index) => ({ value: String(index), content: `Value ${index}`, })); const longOptions = Array.from({length: 1000}, (_, index) => ({ value: String(index), content: `Loooooooooooooooooooong Value ${index}`, })); export default function () { return ( <> <div style={containerStyle}> <h4>Default</h4> <Box marginBlock="spacing-3"> <ListVirtualizer> <Select placeholder="Short value" options={shortOptions} /> </ListVirtualizer> </Box> <Box marginBlock="spacing-3"> <ListVirtualizer> <Select placeholder="Long value" options={longOptions} /> </ListVirtualizer> </Box> </div> <div style={containerStyle}> <h4>In pixels</h4> <Box marginBlock="spacing-3"> <ListVirtualizer> <Select placeholder="Short value" popupWidth={80} options={shortOptions} /> </ListVirtualizer> </Box> <Box marginBlock="spacing-3"> <ListVirtualizer> <Select placeholder="Long value" popupWidth={80} options={longOptions} /> </ListVirtualizer> </Box> </div> </> ); }
§Accessible name
The trigger needs a name: label, aria-label, aria-labelledby or a <label htmlFor> pointing at the id of the Select. label names the trigger and stays out of its value; a placeholder is not a name. With renderControl the label is not drawn, so name the custom control yourself.
§Advanced usage
There are many ways to customize your Select.
§Rendering custom control
To render a custom control, use the renderControl property.
Hand ref to your element and spread triggerProps onto it: they open and close the popup, carry the keyboard of the list and the ARIA of the combobox (role, aria-expanded, aria-controls, aria-activedescendant). A control that keeps them to itself neither opens nor navigates. triggerProps also contains disabled. Cast the generic ref to a button ref when using Button.
import {Button, Select} from '@gravity-ui/uikit'; import type {Ref} from 'react'; export default function () { return ( <Select renderControl={({ref, triggerProps}) => ( <Button ref={ref as Ref<HTMLButtonElement>} {...triggerProps}> Custom control </Button> )} > <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> ); }
§Rendering custom filter section
To render a custom filter section, use the renderFilter property and set the filterable property to true.
inputProps carries everything the input of a combobox needs: the value, the handlers, the placeholder and the ARIA wiring — role, aria-label, aria-controls, aria-activedescendant, aria-expanded, aria-autocomplete. It also carries size: 1, a width hint rather than ARIA: it lets the input shrink to the popup instead of keeping the twenty characters an input asks for by default. Without them the filter has no accessible name and names no active option for a screen reader. Spread it onto a plain input together with ref. A component with an API of its own — TextInput, say — takes the props it owns (value, placeholder, onChange, onKeyDown) and hands the rest to the element through controlProps, which one line of destructuring does; onKeyDown must be among them, it carries the whole keyboard of the list.
import type {SelectProps} from '@gravity-ui/uikit'; import {Button, Flex, Select, TextInput} from '@gravity-ui/uikit'; const renderFilter: SelectProps['renderFilter'] = ({ref, style, inputProps}) => { // `TextInput` owns the value, the placeholder and the handlers; everything else belongs to the // input element itself and goes through `controlProps` as it is const {value, placeholder, onChange, onKeyDown, ...controlProps} = inputProps; return ( <Flex direction="column" gap="spacing-1" style={style}> <TextInput controlRef={ref} controlProps={controlProps} value={value} placeholder={placeholder} onChange={onChange} onKeyDown={onKeyDown} /> <Button size="xs">Do smth</Button> </Flex> ); }; export default function () { return ( <Select placeholder="Custom filter" filterable renderFilter={renderFilter}> <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> ); }
§Rendering custom options
To render custom options, use the renderOption property. It is called with the option and with the
state of its row: isItemActive, whether the row is the active one (the one Enter applies);
selected, whether the option is selected; and itemHeight, the height the row comes out as — the
one getOptionHeight returned or the minimum of the
size. The row itself shows the selection beside whatever this renders: a
check mark in a multiple Select and a highlight in a single one.
An option that draws its own indication — a Radio or a Checkbox from selected — turns that
off with selectionStyle="none"; without one of its own the selection becomes invisible. Such a
control is decoration — the row selects the option, and an interactive element is not allowed
inside it: wrap the control in an element with inert (inert="" before React 19) and keep the
text of the option outside it.
renderOptionGroup is the same for the header of a group: the group and {isItemActive, itemHeight}.
import type {SelectProps} from '@gravity-ui/uikit'; import {Select} from '@gravity-ui/uikit'; const renderOption: SelectProps['renderOption'] = (option) => { return <div style={{color: option.data.color}}>{option.children}</div>; }; export default function () { return ( <Select placeholder="Custom options" renderOption={renderOption}> <Select.Option value="val_1" data={{color: '#8FE1A1'}}> Value 1 </Select.Option> <Select.Option value="val_2" data={{color: '#38C0A8'}}> Value 2 </Select.Option> <Select.Option value="val_3" data={{color: '#3A7AC3'}}> Value 3 </Select.Option> <Select.Option value="val_4" data={{color: '#534581'}}> Value 4 </Select.Option> </Select> ); }
§Rendering custom selected options
To render the selection in the control, use the renderSelectedOptions property. It is called with
all the selected options in the order of value — an array of one in a single select — and only
when there is a value. A value without an option comes as {value}, without content. Give the
returned elements keys when they hold state. The label, placeholder, counter and clear button stay
with the Select. Without the property the control shows the texts of the options joined with , .
import type {SelectProps} from '@gravity-ui/uikit'; import {Select} from '@gravity-ui/uikit'; const options = [ {value: 'bug', content: 'Bug'}, {value: 'task', content: 'Task'}, {value: 'epic', content: 'Epic'}, ]; const renderSelectedOptions: SelectProps['renderSelectedOptions'] = (selected) => selected.length === options.length ? 'All ticket types' : selected.map((option) => option.content ?? option.value).join(' and '); export default function () { return ( <Select multiple placeholder="Ticket types" options={options} renderSelectedOptions={renderSelectedOptions} /> ); }
§Rendering options with different heights
A row is as tall as its content, and no shorter than the minimum of its size (24, 28, 36 and 44 pixels, as the control of the same size; on mobile every row takes the 44 of xl) — unless you set the height yourself. If you need to render options with different heights, you can use the option.data property. It will store information about what height you need to set for the options, as well as the getOptionHeight property to set this value: the number it returns becomes the height of the row and the estimate the virtualizer positions the rows with.
import type {SelectProps} from '@gravity-ui/uikit'; import {Select} from '@gravity-ui/uikit'; const getOptionHeight: SelectProps['getOptionHeight'] = (option) => option.data.height; export default function () { return ( <Select placeholder="Different heights" getOptionHeight={getOptionHeight}> <Select.Option value="val_1" data={{height: 20}}> Value 1 </Select.Option> <Select.Option value="val_2" data={{height: 40}}> Value 2 </Select.Option> <Select.Option value="val_3" data={{height: 60}}> Value 3 </Select.Option> <Select.Option value="val_4" data={{height: 80}}> Value 4 </Select.Option> </Select> ); }
§Rendering custom counter
To render a custom counter, use the renderCounter property. The counter is only displayed when multiple selection is enabled (multiple={true}) and hasCounter={true}.
import type {SelectProps} from '@gravity-ui/uikit'; import {Select} from '@gravity-ui/uikit'; const renderCounter: SelectProps['renderCounter'] = (_, {count, disabled}) => { if (count === 0) { return null; } if (count >= 2) { return ( <div style={{ padding: '0 8px', color: disabled ? '#999' : '#027bf3', fontWeight: 'bold', }} > +{count} </div> ); } return count; }; export default function () { return ( <Select multiple hasCounter renderCounter={renderCounter}> <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> ); }
§Rendering options list
The renderPopup property allows you to control the content of the options list: change the order of standard elements (filter, list), hide them, or add custom elements between, before, or after them.
import type {SelectProps} from '@gravity-ui/uikit'; import {Select} from '@gravity-ui/uikit'; const renderPopup: SelectProps['renderPopup'] = ({renderList, renderFilter}) => { return ( <> {renderFilter()} <div style={{width: '100%', height: 20, backgroundColor: 'tomato'}} /> {renderList()} </> ); }; export default function () { return ( <Select filterable placeholder="Custom popup" renderPopup={renderPopup}> <Select.Option value="val_1" data={{color: '#8FE1A1'}}> Value 1 </Select.Option> <Select.Option value="val_2" data={{color: '#38C0A8'}}> Value 2 </Select.Option> <Select.Option value="val_3" data={{color: '#3A7AC3'}}> Value 3 </Select.Option> <Select.Option value="val_4" data={{color: '#534581'}}> Value 4 </Select.Option> </Select> ); }
§Error
This Select state is for incorrect user input. To change the Select appearance, use the validationState property with the "invalid" value. Optionally, you can provide an error message through the errorMessage property. By default, the message text is rendered outside the component.
You can change this with the errorPlacement property.
import {Select} from '@gravity-ui/uikit'; export default function () { return ( <> <Select placeholder="Placeholder" errorMessage="Error message" validationState="invalid"> <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> <Select placeholder="Placeholder" errorPlacement="inside" errorMessage="Error message" validationState="invalid" > <Select.Option value="val_1">Value 1</Select.Option> <Select.Option value="val_2">Value 2</Select.Option> <Select.Option value="val_3">Value 3</Select.Option> <Select.Option value="val_4">Value 4</Select.Option> </Select> </> ); }
§Properties
| Name | Description | Type | Default |
|---|---|---|---|
| className | Control className | string | |
| defaultValue | Default values that represent selected options in case of using an uncontrolled state | V[] | |
| disabled | Shows that the user cannot work with the control | boolean | false |
| filterable | Shows that select popup has a filter section | boolean | false |
| filterOption | Used to compare option with filter | function | |
| filterPlaceholder | Default filter input placeholder text | string | |
| getOptionText | The text of an option: the trigger, the filter and the search by the first letters use it | function | string content, otherwise the value |
| getValueKey | The string key of a value: the id of its row, the form field, the equality of values | (value: V) => string | the string itself, String() for another primitive |
| getOptionHeight | Used to set height of customized user options | function | |
| getOptionGroupHeight | Used to set height of customized user option group | function | |
| hasClear | Enables displaying icon for clearing selected options | boolean | false |
| id | id HTML attribute | string | |
| label | Control label; on mobile also the title of the sheet | string | |
| loading | Adds the loading item to the end of the option list. Works like a persistent loading indicator while the options list is empty. | boolean | |
| multiple | Shows whether multiple options can be selected in the list | boolean | false |
| name | Name of the control | string | |
| onBlur | Handler that is called when the element loses focus. | function | |
| filter | Controlled filter value | string | '' |
| onFilterChange | Fires every time after changing the filter | function | |
| onFocus | Handler that is called when the element gets focus | function | |
| onLoadMore | Fires when the loading indicator gets visible | function | |
| onOpenChange | Fires every time after changing popup visibility | function | |
| onUpdate | Fires when an alteration to the Select value is committed by the user | function | |
| options | Options to select | SelectOptions | |
| pin | Control border view | string | 'round-round' |
| placeholder | Placeholder text | string | |
| popupClassName | Popup with the option list className | string | |
| popupPlacement | Popup placement | PopupPlacement Array<PopupPlacement> | ['bottom-start', 'bottom-end', 'top-start', 'top-end'] |
| popupWidth | Popup width | number | 'fit' | |
| sheetClassName | Sheet's className | string | |
| qa | Test id attribute (data-qa) | string | |
| renderControl | Used to render user control | function | |
| renderCounter | Used to render user counter. Works only with hasCounter. | function | |
| renderEmptyOptions | Used to render a node for an empty option list | function | |
| renderFilter | Used to render user filter section | function | |
| renderOption | Used to render user options | function | |
| renderOptionGroup | Used to render user option groups | function | |
| renderSelectedOptions | Used to render the selection in the control | function | |
| renderPopup | Used to render options list content | function | |
| selectionStyle | How a row shows that its option is selected: the check mark or highlight (auto) or nothing (none) | 'auto' | 'none' | 'auto' |
| size | Control / options size | string | 'm' |
| value | Values that represent selected options | V[] | |
| view | Control view | string | 'normal' |
| width | Control width | string | number | undefined |
| errorMessage | Error text | string | |
| errorPlacement | Error position | outside inside | outside |
| validationState | Validation state | "invalid" | |
| hasCounter | Shows the selected option count. The counter appears only when the multiple selection is enabled. | boolean |
§CSS API
The class names of the markup are not a public contract — the rows of the popup are rendered by the list and its row view, and their markup changes with the kit. What is supported:
- the variables below;
- the look of a row, through the
--g-list-item-view-*variables of the row view: its colours, and its height, padding and radius, which otherwise follow the size of theSelect. Set them onpopupClassNameorsheetClassName— for example--g-list-item-view-min-height: 48pxfor taller rows on mobile. The estimate of the virtualizer and theitemHeightofrenderOptionstill come from the size: when the exact number matters, usegetOptionHeight; - the content of a row, through
renderOption,renderOptionGroupandrenderSelectedOptions.
| Name | Description |
|---|---|
--g-select-focus-outline-color | Outline color if focused (missing by default) |