structyl

Multi Select

stable

Lets users choose multiple options from a searchable dropdown list.

Basic usage

Examples

Controlled with max selection

Track selected values externally and cap the selection count.

Selected: react

Selected chips and overflow

Selected values render in the trigger and can collapse into an overflow count.

Features

  • Can be controlled or uncontrolled.
  • Shows selected values in the trigger.
  • Supports search, creation and virtualized option rendering.
  • Keeps the listbox open while toggling options.

Installation

bash
pnpm dlx structyl add multi-select

API Reference

MultiSelect.Root

Contains all multi-select parts.

PropTypeDefault
valuestring[]

Controlled selected values.

defaultValuestring[]

Initial selected values.

onValueChange(value: string[]) => void

Called when selected values change.

openboolean

Controlled open state.

onOpenChange(open: boolean) => void

Called when open state changes.

disabledboolean

Disable the multi-select.

false
requiredboolean

Mark as required.

false
namestring

Name for form submission.

searchableboolean

Enable option search.

false
onCreateOption(value: string) => void

Called when a new option is created.

MultiSelect.Trigger

The button that opens the listbox.

PropTypeDefault
classNamestring

Additional Tailwind classes, merged with the component defaults.

MultiSelect.Value

Displays selected values inside the trigger.

PropTypeDefault
placeholderReactNode

Shown when no value is selected.

optionsMultiSelectOption[]

Used to resolve selected value labels.

maxVisiblenumber

Styled wrapper limit before showing an overflow count.

MultiSelect.SearchInput

Search field shown when the root is searchable.

PropTypeDefault
classNamestring

Additional Tailwind classes, merged with the component defaults.

MultiSelect.Content

The multi-selectable listbox popup.

PropTypeDefault
optionsMultiSelectOption[]

Array-backed options rendered with windowing.

optionHeightnumber

Virtual row height in pixels.

36
optionOverscannumber

Extra rows rendered above and below the viewport.

6

MultiSelect.Item

A toggleable option.

PropTypeDefault
valuestring

The value toggled when selected.

disabledboolean

Disable the option.

false
textValuestring

Override the search text.

MultiSelect.CreateItem

Creates and selects the current search text with `onCreateOption`.

PropTypeDefault
classNamestring

Additional Tailwind classes, merged with the component defaults.

MultiSelect.Options

Virtualized renderer for large array-backed option lists.

PropTypeDefault
optionsMultiSelectOption[]

Options to render.

itemHeightnumber

Row height in pixels.

36
overscannumber

Extra rows rendered outside the viewport.

6

MultiSelect.Group

Groups related items.

PropTypeDefault

MultiSelect.Label

A group label.

PropTypeDefault

MultiSelect.Separator

A visual divider.

PropTypeDefault

Keyboard interactions

Adheres to the WAI-ARIA design pattern .

KeyDescription
Space / EnterOpens the multi-select / toggles the focused item.
ArrowDown / ArrowUpMoves focus between options.
EscCloses the multi-select.
Multi Select | structyl