MultiSelect
Choose multiple collection items in a searchable tag field.
Anatomy#
MultiSelect renders its portaled popup internally; the popup names are style slots, not attached parts. Replace tags with tagRender.
Usage#
Use MultiSelect for selecting several collection items shown as tags, or for creatable free-form tags. Each value resolves through a collection item, and items accepts plain strings (shorthand for { value, label }), item objects, groups, and separators.
- Select: single non-editable choice.
- Combobox: editable single selection.
- BaseSelect: headless primitive to compose the listbox yourself.
Values and tags#
value: array of selected item values in selection order. An empty array ([]) means no selection, and an empty string ('') is a valid item value.onValueChangeanddefaultValue: pairvaluewithonValueChangefor controlled selection, or usedefaultValuefor an initial uncontrolled selection.onValueChangereceives the full next array and clears the search text afterward.searchable: lets users type in the field to filter options. Withoutsearchable, printable keys trigger collection typeahead.
clearable shows a clear button while there are selected values or search text. Clicking clear empties the search text and runs onClear after onValueChange, with two selection rules:
- Selected values whose items are
disabledremain selected because the user cannot remove them. - Values that match no item are dropped, while all other selections are cleared (unlike Select and Combobox, which clear to a single empty value).
Search and item creation#
searchable and createItem decide whether the field is editable. Filtering follows editability, so the four combinations behave as follows:
searchable |
createItem |
Field | Filters options | Creates items | openOnControlClick default |
|---|---|---|---|---|---|
| unset | unset | Trigger button, no text input | No | No | true |
true |
unset | Editable input | Yes | No | false |
| unset | set | Editable input | Yes | Yes | false |
true |
set | Editable input | Yes | Yes | false |
searchable alone filters the collection as the user types. createItem makes the input editable, filters the list, and enables creation (searchable adds nothing once createItem is set). filterMethod and autoComplete have no effect on a non-editable control.
openOnControlClick defaults to the opposite of editability:
- Non-editable: opens the popup on control click.
- Editable: focuses the input on control click and opens from typing, the chevron button, or ArrowDown.
Set openOnControlClick explicitly to override either default.
Delimiters#
createItem receives the trimmed query text when the user commits text that matches no existing item by label or value, and returns the TItem to select:
- The created item is added to the top of the option list until a native form reset.
- Nothing is created when the value is already selected or
maxValuesis reached. - Commit text with Enter, a token separator (
tokenSeparators, default[',']), or paste; all go through the same creation path.
Keyboard interaction#
| Key | Behavior |
|---|---|
| Backspace | With an empty input, remove the last removable tag |
| ArrowLeft | At the start of the input, focus the last tag’s remove button |
| ArrowLeft / Right | On a remove button, focus the neighboring removable tag, or return to the input |
| Backspace / Delete | On a remove button, remove that tag and focus a neighbor |
| ArrowDown / ArrowUp | Open the popup and move the highlight through enabled options |
| Enter | Commit the highlighted option, or create an item from the input text |
| Escape | Close the popup; the search text resets once it closes |
| Tab | Close the popup and move focus on |
Virtualization#
Pass a virtualizer from createListVirtualizer when rendering the full collection makes opening
or scrolling slow. Type it over MultiSelectT.Row. Read the Virtualization guide
for setup, row measurement, stable keys, and keyboard navigation.
Examples#
Custom tags#
Use tagRender to style tags from item data such as a color class. Selected values still come
from the collection.
Item descriptions#
Show secondary item metadata with description while rendering each selected option as a tag.
Max values and overflow#
maxValues blocks additional selections by disabling unselected options. maxVisible is visual:
surplus selections stay committed and collapse into a +N summary. Use tagOverflowRender to
render the hidden tags yourself, for example in a tooltip.
Create items#
Pass createItem and an emptyRender action so unmatched text can become a collection item.
The create function in the emptyRender state runs createItem for the current search text.
Free-form tags#
With no predefined items, combine createItem and tokenSeparators for a tag input. Comma, space,
and paste all create tokens.
Groups#
Organize options with type: 'group'. Group labels are non-selectable.
Disabled and read-only#
Disable an option to keep it in the list without allowing toggle. disabled and readOnly on the
root freeze the whole control.
Virtualization#
Pass a createListVirtualizer instance as virtualizer when opening or scrolling the full list is
slow.
Form#
Validate the selected array with createForm. Use a minLength schema rule to fail short
selections; required only checks that something is selected. A selection made only of disabled
items passes constraint validation but submits no value to the native form, as a native
<select multiple> does.
API Reference#
Attributes#
data-closeddata-disableddata-editabledata-expandeddata-invaliddata-readonlydata-requireddata-tagsdata-sidedata-highlighteddata-selecteddata-duplicatedata-loadingProps#
Renders a <div> element by default.