Search documentation

Search pages, components, blocks, styles and colours.

Get started
Skip to content

Multi Select

PreviousNext

Pick several options from a searchable list, shown as chips in the field.

Type to filter, pick with a click or Enter, and keep picking: the list stays open and the search clears after each pick. Every pick becomes a chip in the field. Remove one with its button, or with Backspace in an empty search.

Multi Select is part of the Fabricator style. It's built on Base UI's Combobox in multiple mode, which owns filtering, the keyboard and ARIA, and it shares Combobox's frame, popup and rows. Chips pop in with a small rise, fade and wipe out where they stand while the chips after them glide over. One highlight glides between options and the check scales in on the picked ones. Motion follows the motion speed and stops under reduced motion.

Installation

bunx --bun fabricator-ui@latest add multi-select

Usage

import {
  MultiSelect,
  MultiSelectContent,
  MultiSelectEmpty,
  MultiSelectInput,
  MultiSelectItem,
  MultiSelectList,
  MultiSelectTrigger,
  MultiSelectValue,
} from "@/components/ui/multi-select"
const frameworks = ["Next.js", "Remix", "Astro", "SvelteKit"]
 
<MultiSelect items={frameworks}>
  <MultiSelectTrigger>
    <MultiSelectValue />
    <MultiSelectInput aria-label="Frameworks" placeholder="Add frameworks" />
  </MultiSelectTrigger>
  <MultiSelectContent>
    <MultiSelectEmpty>No frameworks found.</MultiSelectEmpty>
    <MultiSelectList>
      {(framework: string) => (
        <MultiSelectItem key={framework} value={framework}>
          {framework}
        </MultiSelectItem>
      )}
    </MultiSelectList>
  </MultiSelectContent>
</MultiSelect>

Composition

MultiSelect                     Combobox.Root, always `multiple`
├── MultiSelectTrigger          the field: Combobox.InputGroup
│   ├── MultiSelectValue        a chip per picked item
│   │   └── chip + remove button
│   ├── MultiSelectInput        the search, a combobox input
│   └── chevron
└── MultiSelectContent          the popup, anchored to the field
    ├── MultiSelectEmpty
    └── MultiSelectList
        └── MultiSelectGroup
            ├── MultiSelectLabel
            ├── MultiSelectCollection
            │   └── MultiSelectItem
            └── MultiSelectSeparator

Items work like Combobox's: pass them to items and render them in MultiSelectList. Strings work as they are. Objects with value and label show their label in the chip and search by it. Pass children to MultiSelectValue to draw a chip yourself: {(item) => …}.

Examples

Field

Point a FieldLabel at the input's id and describe it with FieldDescription.

Pick every language the role uses. Backspace removes the last one.

Controlled

Control the picks with value and onValueChange. Setting value from outside animates the chips too.

2 selected

Invalid

Set aria-invalid on the input and data-invalid on the Field.

Disabled

API Reference

MultiSelect

Every Combobox.Root prop except multiple, which is always on.

PropTypeDefault
itemsItem[] | { value, items }[]-
valueItem[]-
defaultValueItem[]-
onValueChange(value: Item[], details) => void-
autoHighlightbooleantrue
disabledbooleanfalse
namestring-

Picking an item doesn't close the list, so onOpenChange never reports an item-press close. The search clears after each pick and onInputValueChange reports it.

MultiSelectValue

PropTypeDefault
children(item: Item) => ReactNodethe item label

Data attributes

AttributeElementPresent when
data-slot="multi-select-trigger"the fieldalways
data-slot="multi-select-chip"each chipan item is picked
data-exitinga chipit's leaving
data-slot="multi-select-chip-remove"a chip's buttonan item is picked
data-slot="multi-select-input"the searchalways
data-slot="multi-select-content"the popupopen
data-slot="multi-select-item"each optionopen
data-selectedan optionit's picked

Accessibility

  • The search is a combobox input. Label it with a FieldLabel or aria-label; the list is aria-multiselectable.
  • Up and Down move through the options, Enter picks or unpicks, and Escape closes. Typing filters.
  • Backspace in an empty search removes the last chip. Left Arrow at the start of the search moves into the chips, where Backspace or Delete removes the focused one.
  • Each remove button is named "Remove" and the item's label. A leaving chip is hidden from assistive technology and can't be pressed.
  • Clicking anywhere on the field focuses the search and opens the list.