nook
Browse the docs

Components

Multi select

Built on Base UI

Search many choices, select matching options and remove selected chips.

See the prompt
  • Amelia Chen
  • Rafael Costa
2 selected

Installation

npx nook-ui@latest add multi-select

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Multi select" component to this project, exactly as Nook ships it.

Search many choices, select matching options and remove selected chips.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add multi-select`. It writes `components/ui/multi-select.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/multi-select.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
import { MultiSelect } from "@/components/ui/multi-select";
export default function Example() {
  return (
    <div className="w-full max-w-sm">
      <MultiSelect
        label="Project reviewers"
        name="reviewers"
        defaultValue={["amelia", "rafael"]}
        items={[
          { value: "amelia", label: "Amelia Chen" },
          { value: "rafael", label: "Rafael Costa" },
          { value: "nora", label: "Nora Williams" },
          { value: "ayu", label: "Ayu Pratama" },
          { value: "liam", label: "Liam O’Brien (away)", disabled: true },
        ]}
      />
    </div>
  );
}
```

API
- `MultiSelect`: Search many choices, select matching options and remove selected chips.
  - `items` (`MultiSelectItem[]`): Choices with value, label and disabled state.
  - `value / defaultValue` (`string[]`): Selected choice IDs.
  - `onValueChange` (`(value: string[]) => void`): Receives selections.
  - `label` (`string`): Name of the selection field.
  - `name` (`string`): Submits one hidden value for each choice.

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Named checkbox controls retain native Space behavior; Base UI returns focus after dismissal.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { MultiSelect } from "@/components/ui/multi-select";
export default function Example() {
  return (
    <div className="w-full max-w-sm">
      <MultiSelect
        label="Project reviewers"
        name="reviewers"
        defaultValue={["amelia", "rafael"]}
        items={[
          { value: "amelia", label: "Amelia Chen" },
          { value: "rafael", label: "Rafael Costa" },
          { value: "nora", label: "Nora Williams" },
          { value: "ayu", label: "Ayu Pratama" },
          { value: "liam", label: "Liam O’Brien (away)", disabled: true },
        ]}
      />
    </div>
  );
}

Examples

Preselected

  • React
  • TypeScript
  • Accessibility
3 selected

Disabled

  • Node.js
  • SQL
2 selected

Skills are managed by your admin.

Inside a form

Each choice is submitted under the field name.

  • Go
1 selected

Controlled with a limit

Keep the value in your own state, and say when a limit is reached.

  • React
1 selected

Pick up to three skills.

Props

MultiSelect

Search many choices, select matching options and remove selected chips.

PropTypeDefaultDescription
itemsMultiSelectItem[]–Choices with value, label and disabled state.
value / defaultValuestring[]–Selected choice IDs.
onValueChange(value: string[]) => void–Receives selections.
labelstring–Name of the selection field.
namestring–Submits one hidden value for each choice.

Accessibility

Named checkbox controls retain native Space behavior; Base UI returns focus after dismissal.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.