Components
MultiSelect
Multiple selection with removable chips, a clear-all button and announced removals.
Client component ("use client")
import.tsx
value: ["es","ja"] multi-select-basic.tsx
Edit on GitHubPurpose
MultiSelect chooses several values from a list. Selected values appear as removable chips beside
the trigger.
Import
import { MultiSelect } from "@neshel-ui/components";Usage
Preview: multi-select-basic
- Spanish
- Japanese
"use client";
import { Label, MultiSelect } from "@neshel-ui/components";
import { Stack } from "@neshel-ui/layout";
import { Text } from "@neshel-ui/typography";
import { useState } from "react";
const languages = [
{ value: "es", label: "Spanish" },
{ value: "en", label: "English" },
{ value: "fr", label: "French" },
{ value: "ja", label: "Japanese" },
{ value: "pt", label: "Portuguese" },
];
export default function MultiSelectBasic() {
const [value, setValue] = useState<string[]>(["es", "ja"]);
return (
<Stack space="5" className="max-w-md">
<Stack space="2">
<Label htmlFor="multi-languages">Languages</Label>
<MultiSelect
id="multi-languages"
name="languages"
options={languages}
value={value}
onValueChange={setValue}
placeholder="Select languages"
/>
<Text tone="muted" size="sm">
value: {JSON.stringify(value)}
</Text>
</Stack>
<Stack space="2">
<Label htmlFor="multi-summary">Summary only (no chips)</Label>
<MultiSelect id="multi-summary" options={languages} chips={false} defaultValue={["fr"]} />
</Stack>
</Stack>
);
}API
MultiSelectProps
| Prop | Type | Default | Description |
|---|---|---|---|
| aria-describedby | string | — | — |
| aria-label | string | — | — |
| aria-labelledby | string | — | — |
| chips | boolean | true | Show removable chips for the selected values (default true). |
| className | string | — | — |
| clearLabel | string | "Clear selection" | Accessible name of the clear-all button (default "Clear selection"). |
| clearable | boolean | true | Show a "clear all" button when values are selected (default true). |
| container | HTMLElement | null | — | Portal target for the popup (default: the enclosing Neshel overlay, else document.body). |
| defaultOpen | boolean | — | — |
| defaultValue | readonly string[] | — | Initial selected values when uncontrolled. |
| disabled | boolean | — | — |
| form | string | — | — |
| id | string | — | Id of the focusable control; associate a <Label htmlFor> with it. |
| invalid | boolean | — | Marks the control aria-invalid. Describe the error with aria-describedby. |
| name | string | — | Form field name; one entry per selected value. |
| onOpenChange | (open: boolean) => void | — | — |
| onValueChange | (value: string[]) => void | — | Called with the new list of values. |
| open | boolean | — | — |
| options(required) | SelectOptions | — | Options, flat or grouped. |
| placeholder | string | — | Text shown when nothing is selected. |
| readOnly | boolean | — | — |
| ref | Ref<HTMLButtonElement> | — | — |
| removeLabel | (label: string) => string | Remove <label> | Accessible name of a chip's remove button (default: Remove <label>). |
| removedMessage | (label: string) => string | <label> removed | Live-region announcement after a removal (default: <label> removed). |
| required | boolean | — | — |
| summary | (count: number) => string | <n> selected | Trigger text for the selection count (default: <n> selected). |
| uiSize | FieldSize | "md" | Field size (default "md"). |
| value | readonly string[] | — | Controlled selected values. |
Options use the same SelectOption / SelectOptionGroup shapes as Select.
Controlled and uncontrolled
defaultValue / value (string[]) with onValueChange.
Forms
With name, each selected value becomes a form entry (formData.getAll(name)).
Accessibility
- Chips sit beside the trigger — never inside it — so there is no interactive content inside a
button. Each chip has a remove button labelled by
removeLabel("Remove Spanish"). - Removals are announced in a polite live region (
removedMessage), and focus moves to the next chip. chips={false}shows only a summary in the trigger (summary, "2 selected").- All labels are props, so you can translate them.
Keyboard
| Key | Action |
|---|---|
| Enter / Space / ↓ | Open the listbox |
| ↓ / ↑, Home / End | Move between options |
| Enter / Space | Toggle the option (popup stays open) |
| Escape | Close; the selection is kept |
| Tab to a chip's remove button, Enter | Remove that value |
Common mistakes
- Untranslated labels in non-English interfaces: pass
removeLabel,removedMessage,summaryandclearLabel. - Long lists without search: use Combobox with
multiple.