Components

Multi Select

new

A searchable multi-select with badges in the field, groups, a create row and a limit.

Next.jsAstro
Type to search. Backspace removes the last one.

Installation

npx shadcn@latest add @blank/multi-select

Usage

import { MultiSelect } from "@/components/ui/multi-select"
<MultiSelect
  options={[
    { value: "next", label: "Next.js" },
    { value: "astro", label: "Astro" },
  ]}
  defaultValue={["next"]}
  placeholder="Pick frameworks…"
/>

The field is the search box: type to filter, arrow keys move through the list, Enter toggles, Backspace in an empty field drops the last pick. Picked options stay in the list with a check, so a second Enter undoes a pick.

Multi Select takes an options array and does the rest. When you need custom rows or async data, compose Combobox with its chips instead.

Examples

Groups, limit and creating options

Options with a group are listed under a heading. Once maxCount is reached the remaining options dim, and picking one is refused through onMaxCount, so the reason can show in FieldError. creatable offers the typed text as a new option when nothing matches it exactly.

Bug
Grouped options, up to three, and new labels on the fly.

API Reference

PropTypeDefault
options{ value, label, disabled?, group? }[]—
value / defaultValuestring[][]
onValueChange(value: string[]) => void—
maxCountnumber—
onMaxCount(maxCount: number) => void—
creatablebooleanfalse
onCreateOption(label: string) => string | void—
createLabel(query: string) => ReactNodeCreate "…"
placeholderstring—
emptyMessageReactNode"No results."
size"default" | "sm""default"
open / defaultOpen / onOpenChangelist state—
idstring—
disabledbooleanfalse
namestring—
aria-invalidboolean—