Skip to content
synccn

Multi Select

New

Searchable list for picking several options, shown as chips.

Installation

$ pnpm dlx shadcn@latest add @synccn/multi-select

First time in this project? Connect synccn with one command.

Usage

import { MultiSelect } from "@/components/ui/multi-select";<MultiSelect options={skills} max={5} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

MultiSelect

Pick several options from a searchable list; selections show as removable chips.

  • optionsrequired
    { value: string; label: string }[]

    Choices.

  • value
    string[]

    Controlled selection.

  • defaultValue
    string[]

    Default []

    Initial selection when uncontrolled.

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

    Called with the new selection.

  • placeholder
    string

    Default "Select options"

    Shown when nothing is selected.

  • max
    number

    Most items that can be picked.

  • maxChips
    number

    Default 3

    Chips shown before “+N more”.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseAutoSide (flips to the side with room), useClickOutside (closes on an outside click), useControllable (works controlled or uncontrolled), useEscape (closes on Escape), usePresence (animates in and out)

npm packages

Keyboard

  • EnterorSpaceor↓Open the list
  • ↓or↑Move between options
  • EnterAdd or remove the highlighted option
  • EscClose the list

Accessibility

  • Each chosen chip has its own remove button with an accessible label.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: combobox, listbox, option
  • ARIA attributes: aria-disabled, aria-expanded, aria-label, aria-multiselectable, aria-selected
  • Keys handled: ArrowUp, ArrowDown, Enter, Space
  • Closes with Escape
  • Closes when you click or tap outside
  • Flips to whichever side has room, so it stays on screen
  • Shows a visible focus ring for keyboard users