structyl

Multi Select API

View component

The full prop reference for the Multi Select component. Lets users choose multiple options from a searchable dropdown list.

Import

tsx
import { MultiSelect } from '@structyl/styled';

Props

Root

The root compound component that provides context and state management for the multi-select

PropTypeDefault
children#React.ReactNode

The child components (Trigger, Content, etc.)

value#string[]

Controlled value of selected items

defaultValue#string[]

Initial selected values when uncontrolled

[]
onValueChange#(value: string[]) => void

Callback fired when selected values change

open#boolean

Controlled open state of the content panel

defaultOpen#boolean

Initial open state when uncontrolled

false
onOpenChange#(open: boolean) => void

Callback fired when open state changes

disabled#boolean

Disables the entire multi-select

required#boolean

Marks the input as required

false
searchable#boolean

Enables search input to filter options

false
searchValue#string

Controlled search input value

defaultSearchValue#string

Initial search value when uncontrolled

''
onSearchValueChange#(value: string) => void

Callback fired when search input changes

filterOption#(option: MultiSelectFilterOption, searchValue: string) => boolean

Custom filter function for search; defaults to text/value matching

onCreateOption#(value: string) => void

Callback when a new option is created from search input

createOptionLabel#React.ReactNode | ((value: string) => React.ReactNode)

Label or function returning label for the create option item

resetSearchOnClose#boolean

Clear search input when content closes

true
dir#'ltr' | 'rtl'

Text direction

name#string

HTML name attribute for form submission

autoComplete#string

HTML autoComplete attribute

Trigger

The button that opens/closes the content panel

PropTypeDefault
asChild#boolean

Render as child element instead of button

className#string

CSS class names to apply

children#React.ReactNode

Trigger content (typically Value and Icon)

disabled#boolean

Disables the trigger button

onClick#React.MouseEventHandler<HTMLButtonElement>

Click event handler

onPointerDown#React.PointerEventHandler<HTMLButtonElement>

Pointer down event handler

onKeyDown#React.KeyboardEventHandler<HTMLButtonElement>

Keyboard event handler

Value

Displays selected items or placeholder text in the trigger

PropTypeDefault
placeholder#React.ReactNode

Text shown when no items selected (primitives only)

options#MultiSelectOption[]

Array of options to map selected values (primitives only)

separator#React.ReactNode

Separator between items when rendering text (primitives only)

', '
children#React.ReactNode | ((selected: MultiSelectSelectedOption[]) => React.ReactNode)

Custom render function or static content

asChild#boolean

Render as child element instead of span

className#string

CSS class names to apply

itemClassName#string

CSS class names for each selected item badge (styled only)

overflowClassName#string

CSS class names for overflow indicator (styled only)

maxVisible#number

Maximum visible items before showing +N overflow (styled only)

Icon

Dropdown icon indicator shown in trigger

PropTypeDefault
asChild#boolean

Render as child element instead of span

className#string

CSS class names to apply

children#React.ReactNode

Icon content (text or SVG)

'▼'

SearchInput

Search input field to filter options; only renders when Root searchable=true

PropTypeDefault
asChild#boolean

Render as child element instead of input

className#string

CSS class names to apply

placeholder#string

Input placeholder text (styled only)

'Search options...'
aria-label#string

Accessibility label

'Search options'
disabled#boolean

Disables the search input

onChange#React.ChangeEventHandler<HTMLInputElement>

Change event handler

onKeyDown#React.KeyboardEventHandler<HTMLInputElement>

Keyboard event handler

Content

Container for options; renders as portal with Popper positioning

PropTypeDefault
asChild#boolean

Render as child element instead of div

className#string

CSS class names to apply

forceMount#boolean

Force mount the content even when closed

position#'item-aligned' | 'popper'

Positioning strategy

'popper'
side#'top' | 'right' | 'bottom' | 'left'

Preferred side for popper positioning

'bottom'
sideOffset#number

Distance from trigger when using popper

4
align#'start' | 'center' | 'end'

Alignment relative to trigger

'start'
alignOffset#number

Fine-tune alignment distance

avoidCollisions#boolean

Reposition to avoid viewport collisions

true
collisionPadding#number

Space to maintain from viewport edges

onCloseAutoFocus#(event: Event) => void

Callback when content closes; focus normally returns to trigger

onEscapeKeyDown#(event: KeyboardEvent) => void

Callback when Escape key pressed

onPointerDownOutside#(event: Event) => void

Callback when pointer down outside content

children#React.ReactNode

Option items (Item, Group, etc.) or custom content

options#MultiSelectOption[]

Array of options to virtualize; auto-renders with Options component (styled only)

optionHeight#number

Height of each virtualized option in pixels (styled only)

36
optionOverscan#number

Extra items to render outside viewport (styled only)

6
optionEmptyMessage#React.ReactNode

Message shown when no options match search (styled only)

renderOption#(option: MultiSelectOption) => React.ReactNode

Custom render function for each option (styled only)

showCreateItem#boolean

Show create option item; requires Root onCreateOption (styled only)

true

Item

Individual option item in the list

PropTypeDefault
value#string

Unique value for this option

disabled#boolean

Disables selection of this item

textValue#string

Text used for search filtering; defaults to extracted text from children

asChild#boolean

Render as child element instead of div

className#string

CSS class names to apply

children#React.ReactNode

Item content/label

onClick#React.MouseEventHandler<HTMLDivElement>

Click event handler

onPointerMove#React.PointerEventHandler<HTMLDivElement>

Pointer move event handler

onPointerLeave#React.PointerEventHandler<HTMLDivElement>

Pointer leave event handler

onKeyDown#React.KeyboardEventHandler<HTMLDivElement>

Keyboard event handler

ItemText

Text label container within Item; auto-managed in styled version

PropTypeDefault
asChild#boolean

Render as child element instead of span

className#string

CSS class names to apply

children#React.ReactNode

Item text content

ItemIndicator

Checkmark or selection indicator shown in selected items; auto-managed in styled version

PropTypeDefault
asChild#boolean

Render as child element instead of span

className#string

CSS class names to apply

children#React.ReactNode

Indicator icon content; only renders when item is selected

CreateItem

Dynamic item for creating new options from search input; only renders when searchable and onCreateOption provided

PropTypeDefault
value#string

Override the create item value (defaults to current search value)

asChild#boolean

Render as child element instead of div

className#string

CSS class names to apply

children#React.ReactNode | ((value: string) => React.ReactNode)

Custom render or text; receives search value; defaults to 'Create "value"'

onClick#React.MouseEventHandler<HTMLDivElement>

Click event handler

onPointerMove#React.PointerEventHandler<HTMLDivElement>

Pointer move event handler

onPointerLeave#React.PointerEventHandler<HTMLDivElement>

Pointer leave event handler

onKeyDown#React.KeyboardEventHandler<HTMLDivElement>

Keyboard event handler

Options

Virtualized container for options with automatic rendering from array

PropTypeDefault
options#MultiSelectOption[]

Array of options to virtualize and render

itemHeight#number

Height of each option item in pixels

36
overscan#number

Extra items to render outside visible viewport

6
visibleItemCount#number

Estimated visible items for height calculation

8
emptyMessage#React.ReactNode

Message shown when no options match search

'No options found.'
itemClassName#string

CSS class names applied to each Item

itemTextClassName#string

CSS class names applied to each ItemText

itemIndicatorClassName#string

CSS class names applied to each ItemIndicator

renderOption#(option: MultiSelectOption) => React.ReactNode

Custom render function for option content

renderItemIndicator#(option: MultiSelectOption) => React.ReactNode

Custom render function for selection indicator

asChild#boolean

Render as child element instead of div

className#string

CSS class names to apply

Group

Container for grouped options with optional label

PropTypeDefault
asChild#boolean

Render as child element instead of div

className#string

CSS class names to apply

children#React.ReactNode

Label, items, and other content

Label

Label for grouped options

PropTypeDefault
asChild#boolean

Render as child element instead of div

className#string

CSS class names to apply

children#React.ReactNode

Label text or content

Separator

Visual divider between groups

PropTypeDefault
asChild#boolean

Render as child element instead of div

className#string

CSS class names to apply

Portal

Portal container for rendering content outside DOM hierarchy (primitives only)

PropTypeDefault
container#Element | DocumentFragment | null

DOM node to portal content into; defaults to document.body

forceMount#boolean

Force mount content even when closed

children#React.ReactNode

Portal content (usually Content component)

Viewport

Scrollable container for options (primitives only)

PropTypeDefault
asChild#boolean

Render as child element instead of div

className#string

CSS class names to apply

children#React.ReactNode

Option items and content

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.

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library