Skip to Content
Neshel-UI
Components

MultiSelect

Multiple selection with removable chips, a clear-all button and announced removals.

Client component ("use client")

Purpose

MultiSelect chooses several values from a list. Selected values appear as removable chips beside the trigger.

Import

import.tsx
import { MultiSelect } from "@neshel-ui/components";

Usage

Preview: multi-select-basic
Preview theme
  • Spanish
  • Japanese
value: ["es","ja"]
multi-select-basic.tsx
"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

MultiSelectProps
PropTypeDefaultDescription
aria-describedbystring——
aria-labelstring——
aria-labelledbystring——
chipsbooleantrueShow removable chips for the selected values (default true).
classNamestring——
clearLabelstring"Clear selection"Accessible name of the clear-all button (default "Clear selection").
clearablebooleantrueShow a "clear all" button when values are selected (default true).
containerHTMLElement | null—Portal target for the popup (default: the enclosing Neshel overlay, else document.body).
defaultOpenboolean——
defaultValuereadonly string[]—Initial selected values when uncontrolled.
disabledboolean——
formstring——
idstring—Id of the focusable control; associate a <Label htmlFor> with it.
invalidboolean—Marks the control aria-invalid. Describe the error with aria-describedby.
namestring—Form field name; one entry per selected value.
onOpenChange(open: boolean) => void——
onValueChange(value: string[]) => void—Called with the new list of values.
openboolean——
options(required)SelectOptions—Options, flat or grouped.
placeholderstring—Text shown when nothing is selected.
readOnlyboolean——
refRef<HTMLButtonElement>——
removeLabel(label: string) => stringRemove <label>Accessible name of a chip's remove button (default: Remove <label>).
removedMessage(label: string) => string<label> removedLive-region announcement after a removal (default: <label> removed).
requiredboolean——
summary(count: number) => string<n> selectedTrigger text for the selection count (default: <n> selected).
uiSizeFieldSize"md"Field size (default "md").
valuereadonly 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

KeyAction
Enter / Space / ↓Open the listbox
↓ / ↑, Home / EndMove between options
Enter / SpaceToggle the option (popup stays open)
EscapeClose; the selection is kept
Tab to a chip's remove button, EnterRemove that value

Common mistakes

  • Untranslated labels in non-English interfaces: pass removeLabel, removedMessage, summary and clearLabel.
  • Long lists without search: use Combobox with multiple.
Edit on GitHub

On this page