MultiSelect
Multi-value selection with removable tags, inline search, and an optional cap.
TypeScriptReact
"use client";
import { useState } from "react";
import { MultiSelect, Box } from "astralis-ui";
const skills = [
{ value: "ts", label: "TypeScript" },
{ value: "react", label: "React" },
{ value: "css", label: "CSS" },
{ value: "a11y", label: "Accessibility" },
{ value: "testing", label: "Testing" },
];
export function MultiSelectDemo() {
const [selected, setSelected] = useState<Array<string | number>>(["ts", "react"]);
return (
<Box w="full" maxW="xs">
<MultiSelect
options={skills}
value={selected}
onChange={setSelected}
placeholder="Pick your skills…"
/>
</Box>
);
}Import#
import { MultiSelect } from "astralis-ui";Usage#
Selections render as removable chips in the trigger; typing filters the options, and Backspace with an empty search removes the last chip — the interaction set people know from tag pickers.
Max and disabled options#
"use client";
import { MultiSelect, Box } from "astralis-ui";
const toppings = [
{ value: "mushroom", label: "Mushroom" },
{ value: "olive", label: "Olive" },
{ value: "basil", label: "Basil" },
{ value: "pepper", label: "Pepper" },
{ value: "onion", label: "Onion" },
{ value: "pineapple", label: "Pineapple", disabled: true },
];
export function MultiSelectMax() {
return (
<Box w="full" maxW="xs">
{/* Capped at 3; the disabled option can't be chosen at all. */}
<MultiSelect
options={toppings}
max={3}
clearable
colorScheme="green"
placeholder="Up to three toppings…"
/>
</Box>
);
}Props#
| Prop | Type | Default | Description |
|---|---|---|---|
options | { value, label, disabled? }[] or grouped | [] | Option data; same group shape as Select. |
value / defaultValue / onChange | Array<string | number> / same / (values) => void | — / [] / — | Controlled / uncontrolled API. |
max | number | — | Cap on selected items. |
clearable | boolean | false | Clear-all button. |
name | string | — | Renders one hidden input per selected value (repeated name) for native <form> submission. |
placeholder / emptyText / loading | — | — | Same behavior as Select. |
variant / size / colorScheme | — | "outline" / "md" / "brand" | Styling; colorScheme tints the tags. |
invalid / disabled / readOnly | boolean | false | State flags — inherited from Field. |
Keyboard#
| Key | Action |
|---|---|
↓ | Open when closed; move the highlight down |
↑ | Move the highlight up |
Enter | Open; when open, toggle the highlighted option |
| type | Filter the options (typing also opens the list) |
Backspace (empty input) | Remove the last selected chip |
Esc | Close |
Tab | Close and move on |
Accessibility#
Options carry role="option" in a portalled listbox with
aria-multiselectable; chip remove buttons stay out of the tab order —
Backspace is the keyboard path.