Multi select
A field for picking several values from a searchable list: the picks show as removable chips, with groups, disabled options, a limit, an empty state and new values created on the spot. Full keyboard support, controlled or uncontrolled.
npx shadcn@latest add https://dresscodeui.com/r/dresscode/multi-select.json6 examples below; each installs the component with it. They wear whichever DressCode theme you install.
Grouped with search
Countries grouped by region; search matches names, codes and other names, and long picks fold into “+N more”.
npx shadcn@latest add https://dresscodeui.com/r/dresscode/multi-select-grouped.json"use client"
// Sales regions: pick countries grouped by region. Search matches names, codes and other names
// ("UK", "Holland"), countries that are not supported yet are disabled, and the field folds long
// lists into "+N more" while you are not editing it.
import * as React from "react"
import { Badge } from "@/components/ui/badge"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { Label } from "@/components/ui/label"
import {
MultiSelect,
type MultiSelectOption,
type MultiSelectOptionGroup,
} from "@/components/ui/multi-select"
type Country = MultiSelectOption & { note?: string }
const country = (value: string, label: string, extra: Partial<Country> = {}): Country => ({
value,
label,
...extra,
keywords: [value, ...(extra.keywords ?? [])],
})
const REGIONS: MultiSelectOptionGroup<Country>[] = [
{
label: "Europe",
options: [
country("AT", "Austria"),
country("BE", "Belgium"),
country("DK", "Denmark"),
country("FI", "Finland"),
country("FR", "France"),
country("DE", "Germany", { keywords: ["Deutschland"] }),
country("IE", "Ireland"),
country("IT", "Italy"),
country("NL", "Netherlands", { keywords: ["Holland"] }),
country("NO", "Norway"),
country("PL", "Poland"),
country("PT", "Portugal"),
country("ES", "Spain", { keywords: ["España"] }),
country("SE", "Sweden"),
country("CH", "Switzerland"),
country("GB", "United Kingdom", { keywords: ["UK", "Britain", "England", "Scotland", "Wales"] }),
],
},
{
label: "North America",
options: [country("CA", "Canada"), country("MX", "Mexico"), country("US", "United States", { keywords: ["USA", "America"] })],
},
{
label: "Latin America",
options: [
country("AR", "Argentina"),
country("BR", "Brazil", { disabled: true, note: "From January" }),
country("CL", "Chile"),
country("CO", "Colombia"),
],
},
{
label: "Asia Pacific",
options: [
country("AU", "Australia"),
country("IN", "India", { disabled: true, note: "Not supported yet" }),
country("JP", "Japan"),
country("NZ", "New Zealand"),
country("SG", "Singapore"),
country("KR", "South Korea", { keywords: ["Korea"] }),
],
},
{
label: "Middle East and Africa",
options: [
country("IL", "Israel"),
country("KE", "Kenya"),
country("NG", "Nigeria"),
country("ZA", "South Africa"),
country("AE", "United Arab Emirates", { keywords: ["UAE", "Dubai"] }),
],
},
]
export default function MultiSelectGrouped() {
const [countries, setCountries] = React.useState<string[]>(["DE", "FR", "NL", "GB", "IE", "ES", "US", "CA", "AU"])
const byRegion = REGIONS.map((r) => ({ label: r.label, count: r.options.filter((c) => countries.includes(c.value)).length })).filter((r) => r.count)
return (
<Card className="mx-auto w-full max-w-xl">
<CardHeader>
<CardTitle>Sales regions</CardTitle>
<CardDescription>Customers in these countries can check out. Prices show in their currency and tax follows the country.</CardDescription>
</CardHeader>
<CardContent className="grid gap-2">
<Label htmlFor="sales-countries">Countries</Label>
<MultiSelect
id="sales-countries"
options={REGIONS}
value={countries}
onValueChange={setCountries}
maxChips={4}
placeholder="Search countries…"
emptyMessage={(query) => (
<>
<span className="font-medium text-foreground">No country matches “{query}”</span>
<span>Try its English name or its two-letter code.</span>
</>
)}
renderOption={(c) => (
<>
<span className="min-w-0 flex-1 truncate">{c.label}</span>
<span className="text-xs text-muted-foreground tabular-nums">{c.note ?? c.value}</span>
</>
)}
/>
<p className="text-xs text-muted-foreground">Brazil opens for checkout in January. India is not supported yet.</p>
</CardContent>
<CardFooter className="flex-wrap gap-1.5">
{byRegion.length ? (
<>
<span className="mr-1 text-xs text-muted-foreground">
{countries.length} {countries.length === 1 ? "country" : "countries"} in {byRegion.length} {byRegion.length === 1 ? "region" : "regions"}
</span>
{byRegion.map((r) => (
<Badge key={r.label} variant="outline" className="tabular-nums">
{r.label} · {r.count}
</Badge>
))}
</>
) : (
<span className="text-xs text-muted-foreground">No countries yet: nobody can check out.</span>
)}
</CardFooter>
</Card>
)
}npx shadcn@latest add https://dresscodeui.com/r/dresscode/multi-select-creatable.json"use client"
// Invoice tags: find a tag or type a new one and pick "Create “…”" (or press Enter). New tags join the
// workspace list, so they show up for the next invoice too.
import * as React from "react"
import { SparklesIcon } from "lucide-react"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Label } from "@/components/ui/label"
import { MultiSelect, type MultiSelectOption } from "@/components/ui/multi-select"
const WORKSPACE_TAGS: MultiSelectOption[] = [
{ value: "retainer", label: "Retainer", description: "Used on 24 invoices" },
{ value: "consulting", label: "Consulting", description: "Used on 18 invoices" },
{ value: "design-sprint", label: "Design sprint", description: "Used on 9 invoices" },
{ value: "recurring", label: "Recurring", description: "Used on 31 invoices" },
{ value: "rush-job", label: "Rush job", description: "Used on 4 invoices" },
{ value: "hardware", label: "Hardware", description: "Used on 6 invoices" },
{ value: "software-licences", label: "Software licences", description: "Used on 11 invoices" },
{ value: "travel", label: "Travel", description: "Used on 7 invoices" },
{ value: "q4-2026", label: "Q4 2026", description: "Used on 15 invoices" },
]
const slug = (text: string) =>
text
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-|-$/g, "")
export default function MultiSelectCreatable() {
const [tags, setTags] = React.useState<MultiSelectOption[]>(WORKSPACE_TAGS)
const [picked, setPicked] = React.useState<string[]>(["retainer", "q4-2026"])
const [lastCreated, setLastCreated] = React.useState<string | null>(null)
const create = (text: string) => {
const label = text.charAt(0).toUpperCase() + text.slice(1)
const value = slug(label) || label
// "Rush job!" is the "Rush job" tag that already exists: pick that one instead of a twin.
const existing = tags.find((t) => t.value === value)
if (existing) return existing
const option = { value, label, description: "New tag" }
setTags((list) => [...list, option])
setLastCreated(label)
return option
}
return (
<Card className="mx-auto w-full max-w-lg">
<CardHeader>
<CardTitle>Tags for INV-1043</CardTitle>
<CardDescription>Tags group invoices in reports. Type to find one, or create a new tag on the spot.</CardDescription>
</CardHeader>
<CardContent className="grid gap-2">
<Label htmlFor="invoice-tags">Tags</Label>
<MultiSelect
id="invoice-tags"
aria-describedby="invoice-tags-hint"
options={tags}
value={picked}
onValueChange={setPicked}
creatable
onCreate={create}
placeholder="Find or create a tag…"
emptyMessage="Type a name to create your first tag."
/>
<p id="invoice-tags-hint" className="flex items-center gap-1.5 text-xs text-muted-foreground" aria-live="polite">
{lastCreated ? (
<>
<SparklesIcon aria-hidden="true" className="size-3.5 text-primary" />
Created “{lastCreated}”. It is in the workspace tag list now.
</>
) : (
`${tags.length} tags in this workspace. Press Enter to create the one you typed.`
)}
</p>
</CardContent>
</Card>
)
}Limit
At most three picks: a meter and hint count them and the rest of the list is disabled once full.
npx shadcn@latest add https://dresscodeui.com/r/dresscode/multi-select-max-count.json"use client"
// Top skills: at most three picks. A meter and a hint count them, the list disables the rest once
// it is full (and says why), and the idle field shows two chips and "+1 more".
import * as React from "react"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Badge } from "@/components/ui/badge"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Label } from "@/components/ui/label"
import { MultiSelect, type MultiSelectOption } from "@/components/ui/multi-select"
import { cn } from "@/lib/utils"
const MAX = 3
const SKILLS: MultiSelectOption[] = [
{ value: "ux-research", label: "UX research" },
{ value: "interaction-design", label: "Interaction design" },
{ value: "visual-design", label: "Visual design" },
{ value: "prototyping", label: "Prototyping" },
{ value: "design-systems", label: "Design systems" },
{ value: "copywriting", label: "UX writing", keywords: ["copywriting", "content"] },
{ value: "illustration", label: "Illustration" },
{ value: "motion-design", label: "Motion design", keywords: ["animation"] },
{ value: "frontend", label: "Frontend development", keywords: ["code", "react"] },
{ value: "accessibility", label: "Accessibility audits", keywords: ["a11y", "wcag"] },
{ value: "workshops", label: "Workshop facilitation" },
{ value: "brand-strategy", label: "Brand strategy" },
]
export default function MultiSelectMaxCount() {
const [skills, setSkills] = React.useState<string[]>(["design-systems", "prototyping", "ux-research"])
const full = skills.length >= MAX
const labels = skills.map((v) => SKILLS.find((s) => s.value === v)?.label ?? v)
return (
<Card className="mx-auto w-full max-w-lg">
<CardHeader>
<CardTitle>Top skills</CardTitle>
<CardDescription>Pick up to three. They show on your public profile and help clients find you in search.</CardDescription>
</CardHeader>
<CardContent className="grid gap-2">
<Label htmlFor="top-skills">Skills</Label>
<MultiSelect
id="top-skills"
aria-describedby="top-skills-hint"
options={SKILLS}
value={skills}
onValueChange={setSkills}
max={MAX}
maxChips={2}
placeholder="Pick up to three skills…"
emptyMessage={(query) => `No skill called “${query}”.`}
/>
<div className="flex items-center gap-3">
<div aria-hidden="true" className="flex gap-1">
{Array.from({ length: MAX }, (_, i) => (
<span key={i} className={cn("h-1.5 w-6 rounded-full transition-colors", i < skills.length ? "bg-primary" : "bg-muted")} />
))}
</div>
<p id="top-skills-hint" aria-live="polite" className="text-xs text-muted-foreground">
{full ? "3 of 3 picked. Remove one to choose another." : `${skills.length} of ${MAX} picked`}
</p>
</div>
<div className="mt-3 rounded-lg border border-border bg-muted/40 p-3">
<p className="mb-2.5 text-xs text-muted-foreground">How clients see it</p>
<div className="flex items-start gap-3">
<Avatar>
<AvatarFallback>ML</AvatarFallback>
</Avatar>
<div className="min-w-0">
<p className="text-sm leading-tight font-medium">Maya Lindqvist</p>
<p className="text-xs text-muted-foreground">Freelance product designer, Oslo</p>
<div className="mt-2 flex flex-wrap gap-1">
{labels.length ? (
labels.map((l) => (
<Badge key={l} variant="outline">
{l}
</Badge>
))
) : (
<span className="text-xs text-muted-foreground">Your top skills show here.</span>
)}
</div>
</div>
</div>
</div>
</CardContent>
</Card>
)
}Assignees
Pick teammates with avatars and roles, shown as avatar chips; the team loads when the list opens.
npx shadcn@latest add https://dresscodeui.com/r/dresscode/multi-select-assignees.json"use client"
// Reviewers: pick teammates with their avatar and role, shown as avatar chips (an avatar stack when
// they fold into "+N"). Composed from the parts, so the chips, rows and overflow are your own markup.
// The team loads when the list first opens, and people who are away can't be picked.
import * as React from "react"
import { CircleCheckIcon } from "lucide-react"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { Label } from "@/components/ui/label"
import { Spinner } from "@/components/ui/spinner"
import {
MultiSelectChip,
MultiSelectChips,
MultiSelectClear,
MultiSelectContent,
MultiSelectEmpty,
MultiSelectField,
MultiSelectFooter,
MultiSelectInput,
MultiSelectItem,
MultiSelectList,
MultiSelectOverflow,
MultiSelectRoot,
MultiSelectStatus,
MultiSelectTrigger,
MultiSelectValue,
} from "@/components/ui/multi-select"
type Person = { value: string; label: string; role: string; initials: string; away?: string }
const TEAM: Person[] = [
{ value: "ada", label: "Ada Lin", role: "Finance lead", initials: "AL" },
{ value: "tom", label: "Tom Okafor", role: "Account manager", initials: "TO" },
{ value: "grace", label: "Grace Mensah", role: "Founder", initials: "GM" },
{ value: "sofia", label: "Sofía Reyes", role: "Bookkeeper", initials: "SR" },
{ value: "maya", label: "Maya Lindqvist", role: "Product designer", initials: "ML" },
{ value: "noah", label: "Noah Fischer", role: "Operations", initials: "NF", away: "Out of office until Dec 2" },
{ value: "kenji", label: "Kenji Watanabe", role: "Engineer", initials: "KW" },
{ value: "priya", label: "Priya Raman", role: "Engineer", initials: "PR" },
{ value: "leo", label: "Léo Martin", role: "Sales", initials: "LM" },
]
const NEEDED = 2
const firstName = (p: Person) => p.label.split(" ")[0]
const fold = (s: string) =>
s
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase()
const listNames = (people: Person[]) =>
people.length < 2 ? people.map(firstName).join("") : `${people.slice(0, -1).map(firstName).join(", ")} and ${firstName(people[people.length - 1])}`
function PersonAvatar({ person, className }: { person: Person; className?: string }) {
return (
<Avatar size="sm" className={className}>
<AvatarFallback className="bg-background text-[10px] font-medium text-foreground">{person.initials}</AvatarFallback>
</Avatar>
)
}
export default function MultiSelectAssignees() {
const [reviewers, setReviewers] = React.useState<Person[]>([TEAM[0], TEAM[1]])
const [team, setTeam] = React.useState<Person[] | null>(null)
const [loading, setLoading] = React.useState(false)
const [requested, setRequested] = React.useState<string | null>(null)
const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined)
React.useEffect(() => () => clearTimeout(timer.current), [])
// Stands in for a request to your API the first time the list opens.
const loadTeam = (open: boolean) => {
if (!open || team || loading) return
setLoading(true)
timer.current = setTimeout(() => {
setTeam(TEAM)
setLoading(false)
}, 700)
}
const missing = Math.max(0, NEEDED - reviewers.length)
return (
<Card className="mx-auto w-full max-w-lg">
<CardHeader>
<CardTitle>Request a review</CardTitle>
<CardDescription>INV-1043 for Fernwood Studio is over $5,000, so two people sign it off before it goes out.</CardDescription>
</CardHeader>
<CardContent className="grid gap-2">
<Label htmlFor="invoice-reviewers">Reviewers</Label>
<MultiSelectRoot<Person>
id="invoice-reviewers"
items={team ?? []}
value={reviewers}
onValueChange={(next) => {
setReviewers(next)
setRequested(null)
}}
isItemEqualToValue={(a, b) => a.value === b.value}
filter={(p, query) => [p.label, p.role].some((text) => fold(text).includes(fold(query.trim())))}
onOpenChange={loadTeam}
autoHighlight
>
<MultiSelectField>
<MultiSelectChips>
<MultiSelectValue<Person>
max={3}
overflow={(hidden) => (
<MultiSelectOverflow className="gap-1 pl-0.5" title={hidden.map((p) => p.label).join(", ")}>
<span className="flex -space-x-1.5">
{hidden.slice(0, 3).map((p) => (
<PersonAvatar key={p.value} person={p} className="size-5 ring-2 ring-background" />
))}
</span>
+{hidden.length}
</MultiSelectOverflow>
)}
>
{(p) => (
<MultiSelectChip key={p.value} removeLabel={`Remove ${p.label}`} className="gap-1.5 pl-0.5">
<PersonAvatar person={p} className="size-5" />
<span className="truncate">{firstName(p)}</span>
</MultiSelectChip>
)}
</MultiSelectValue>
<MultiSelectInput placeholder={reviewers.length ? undefined : "Add reviewers…"} aria-describedby="invoice-reviewers-hint" />
</MultiSelectChips>
<MultiSelectClear />
<MultiSelectTrigger />
</MultiSelectField>
<MultiSelectContent>
<MultiSelectStatus className="sr-only">{loading ? "Loading teammates" : team ? `${team.length} teammates` : ""}</MultiSelectStatus>
<MultiSelectEmpty>
{loading || !team ? (
<span className="flex items-center gap-2">
<Spinner aria-hidden="true" />
Loading teammates…
</span>
) : (
"Nobody on the team matches that name or role."
)}
</MultiSelectEmpty>
<MultiSelectList>
{(p: Person) => (
<MultiSelectItem key={p.value} value={p} disabled={Boolean(p.away)}>
<PersonAvatar person={p} className="size-7" />
<span className="flex min-w-0 flex-1 flex-col">
<span className="truncate">{p.label}</span>
<span className="truncate text-xs text-muted-foreground">{p.away ?? p.role}</span>
</span>
</MultiSelectItem>
)}
</MultiSelectList>
<MultiSelectFooter>Only people who can see invoices are listed.</MultiSelectFooter>
</MultiSelectContent>
</MultiSelectRoot>
<p id="invoice-reviewers-hint" aria-live="polite" className="text-xs text-muted-foreground">
{missing ? `Pick ${missing} more ${missing === 1 ? "reviewer" : "reviewers"}.` : "Each reviewer gets an email and a task in their inbox."}
</p>
</CardContent>
<CardFooter className="flex-wrap justify-end gap-2">
<p aria-live="polite" className="mr-auto flex items-center gap-1.5 text-xs text-muted-foreground">
{requested ? (
<>
<CircleCheckIcon aria-hidden="true" className="size-4 text-primary" />
Review requested from {requested}.
</>
) : null}
</p>
<Button disabled={missing > 0 || Boolean(requested)} onClick={() => setRequested(listNames(reviewers))}>
{requested ? "Requested" : "Request review"}
</Button>
</CardFooter>
</Card>
)
}npx shadcn@latest add https://dresscodeui.com/r/dresscode/multi-select-form-field.json"use client"
// A multi select in a form: label, hint, required validation on submit (the error is linked to the
// field and focus moves there), and the picks submitted as ordinary form values under one name.
// Uncontrolled: the form reads the picks with FormData, the way it reads the other fields.
import * as React from "react"
import { CircleAlertIcon, CircleCheckIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { Checkbox } from "@/components/ui/checkbox"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Spinner } from "@/components/ui/spinner"
import { MultiSelect, type MultiSelectOptionGroup } from "@/components/ui/multi-select"
const RECIPIENTS: MultiSelectOptionGroup[] = [
{
label: "Teams",
options: [
{ value: "team-finance", label: "Finance", description: "4 people" },
{ value: "team-leadership", label: "Leadership", description: "3 people" },
{ value: "team-sales", label: "Sales", description: "6 people" },
{ value: "team-operations", label: "Operations", description: "2 people" },
],
},
{
label: "People",
options: [
{ value: "ada", label: "Ada Lin", description: "Finance lead" },
{ value: "grace", label: "Grace Mensah", description: "Founder" },
{ value: "tom", label: "Tom Okafor", description: "Account manager" },
{ value: "sofia", label: "Sofía Reyes", description: "Bookkeeper" },
{ value: "kato-lee", label: "Kato & Lee", description: "External accountants, read only" },
],
},
]
type Errors = { report?: string; recipients?: string }
function FieldError({ id, children }: { id: string; children?: string }) {
if (!children) return null
return (
<p id={id} className="flex items-center gap-1.5 text-xs text-destructive">
<CircleAlertIcon aria-hidden="true" className="size-3.5 shrink-0" />
{children}
</p>
)
}
export default function MultiSelectFormField() {
const [errors, setErrors] = React.useState<Errors>({})
// "idle", "saving", or how many recipients the saved schedule goes to.
const [status, setStatus] = React.useState<"idle" | "saving" | number>("idle")
const [formKey, setFormKey] = React.useState(0)
const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined)
React.useEffect(() => () => clearTimeout(timer.current), [])
const submit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
const data = new FormData(event.currentTarget)
const report = String(data.get("report") ?? "").trim()
const recipients = data.getAll("recipients").map(String)
const next: Errors = {
report: report ? undefined : "Give the report a name.",
recipients: recipients.length ? undefined : "Pick at least one team or person.",
}
setErrors(next)
if (next.report || next.recipients) {
document.getElementById(next.report ? "report-name" : "report-recipients")?.focus()
return
}
setStatus("saving")
// Stands in for the request that saves the schedule.
timer.current = setTimeout(() => setStatus(recipients.length), 800)
}
const reset = () => {
clearTimeout(timer.current)
setErrors({})
setStatus("idle")
setFormKey((k) => k + 1)
}
const saving = status === "saving"
const done = typeof status === "number"
// Any edit after saving needs a new save.
const edited = () => done && setStatus("idle")
return (
<Card className="mx-auto w-full max-w-lg">
<CardHeader>
<CardTitle>Schedule a report</CardTitle>
<CardDescription>Orbit sends it as a PDF on the 1st of every month.</CardDescription>
</CardHeader>
<form key={formKey} noValidate onSubmit={submit} onChange={edited} className="contents">
<CardContent className="grid gap-5">
<div className="grid gap-2">
<Label htmlFor="report-name">Report</Label>
<Input
id="report-name"
name="report"
defaultValue="Monthly revenue"
required
aria-invalid={errors.report ? true : undefined}
aria-describedby={errors.report ? "report-name-error" : undefined}
onChange={() => errors.report && setErrors((e) => ({ ...e, report: undefined }))}
/>
<FieldError id="report-name-error">{errors.report}</FieldError>
</div>
<div className="grid gap-2">
<Label htmlFor="report-recipients" className="gap-1">
Send to <span className="font-normal text-muted-foreground">(required)</span>
</Label>
<MultiSelect
id="report-recipients"
name="recipients"
required
options={RECIPIENTS}
defaultValue={["team-finance"]}
maxChips={4}
placeholder="Pick teams or people…"
aria-invalid={errors.recipients ? true : undefined}
aria-describedby={errors.recipients ? "report-recipients-hint report-recipients-error" : "report-recipients-hint"}
onValueChange={(value) => {
edited()
if (value.length && errors.recipients) setErrors((e) => ({ ...e, recipients: undefined }))
}}
emptyMessage={(query) => `No team or person called “${query}”.`}
/>
<p id="report-recipients-hint" className="text-xs text-muted-foreground">
Teams include everyone in them now and anyone who joins later.
</p>
<FieldError id="report-recipients-error">{errors.recipients}</FieldError>
</div>
<Label className="w-fit font-normal">
<Checkbox name="csv" defaultChecked />
Attach the numbers as a CSV file too
</Label>
</CardContent>
<CardFooter className="flex-wrap justify-end gap-2">
<p aria-live="polite" className="mr-auto flex items-center gap-1.5 text-xs text-muted-foreground">
{done ? (
<>
<CircleCheckIcon aria-hidden="true" className="size-4 shrink-0 text-primary" />
Sends Dec 1 to {status} {status === 1 ? "recipient" : "recipients"}.
</>
) : null}
</p>
<Button type="button" variant="outline" onClick={reset}>
Reset
</Button>
<Button type="submit" disabled={saving || done}>
{saving ? <Spinner data-icon="inline-start" aria-hidden="true" /> : null}
{saving ? "Scheduling…" : done ? "Scheduled" : "Schedule report"}
</Button>
</CardFooter>
</form>
</Card>
)
}The component
What shadcn@latest add https://dresscodeui.com/r/dresscode/multi-select.json writes. It uses only shadcn/ui's variables, so it follows the theme.
"use client"
// Multi select: pick several values from a searchable list. The picks sit in the field as removable
// chips (folded into "+N more" while the field is idle, if you set maxChips), the list opens below
// with a check box per option, and it can hold groups, disabled options, a most-picks limit, an empty
// or loading state and a "Create “…”" row for values that are not in the list yet.
//
// Built on Base UI's Combobox in multiple mode, the primitive behind shadcn/ui's combobox, so the
// keyboard works as people expect: type to filter, ArrowUp/ArrowDown to move, Enter to toggle,
// Backspace in the empty input removes the last chip, ArrowLeft walks the chips (Backspace or Delete
// removes the focused one), Escape closes the list. Unlike the primitive, Escape never wipes the picks.
// Built for shadcn/ui; reads only the theme's variables.
//
// <MultiSelect options={...} value={...} onValueChange={...} /> the ready field, for most cases
// <MultiSelectRoot> with MultiSelectField, MultiSelectValue, MultiSelectChip, MultiSelectInput,
// MultiSelectContent, MultiSelectList, MultiSelectItem, ... the parts, to compose your own
import * as React from "react"
import { Combobox as ComboboxPrimitive } from "@base-ui/react/combobox"
import { CheckIcon, ChevronDownIcon, LoaderCircleIcon, PlusIcon, XIcon } from "lucide-react"
import { cn } from "@/lib/utils"
type MultiSelectContextValue = {
anchorRef: React.RefObject<HTMLDivElement | null>
open: boolean
/** Focus is in the field or the list is open: every chip shows, none fold into "+N more". */
expanded: boolean
setFocused: (focused: boolean) => void
disabled: boolean
}
const MultiSelectContext = React.createContext<MultiSelectContextValue | null>(null)
function useMultiSelect() {
const context = React.useContext(MultiSelectContext)
if (!context) throw new Error("MultiSelect parts must be inside <MultiSelectRoot>.")
return context
}
// ---------------------------------------------------------------------------------------------
// The parts
type MultiSelectRootProps<Value> = Omit<ComboboxPrimitive.Root.Props<Value, true>, "multiple">
/** Holds the picked values (value/defaultValue/onValueChange) and the list's open state. */
function MultiSelectRoot<Value>({ open: openProp, defaultOpen = false, onOpenChange, disabled = false, ...props }: MultiSelectRootProps<Value>) {
const anchorRef = React.useRef<HTMLDivElement | null>(null)
const [openState, setOpenState] = React.useState(defaultOpen)
const [focused, setFocused] = React.useState(false)
const open = openProp ?? openState
const context = React.useMemo(
() => ({ anchorRef, open, expanded: open || focused, setFocused, disabled }),
[open, focused, disabled],
)
return (
<MultiSelectContext.Provider value={context}>
<ComboboxPrimitive.Root<Value, true>
multiple
open={open}
onOpenChange={(next, details) => {
onOpenChange?.(next, details)
if (!details.isCanceled) setOpenState(next)
}}
disabled={disabled}
{...props}
/>
</MultiSelectContext.Provider>
)
}
type MultiSelectFieldProps = Omit<ComboboxPrimitive.Chips.Props, "className" | "ref"> & { className?: string }
/** The box that looks like an input: chips and the search input on the left, clear and the chevron on the right. */
function MultiSelectField({ className, onFocus, onBlur, ...props }: MultiSelectFieldProps) {
const { anchorRef, setFocused, disabled } = useMultiSelect()
return (
<ComboboxPrimitive.Chips
ref={anchorRef}
data-slot="multi-select-field"
data-disabled={disabled || undefined}
onFocus={(event) => {
onFocus?.(event)
setFocused(true)
}}
onBlur={(event) => {
onBlur?.(event)
if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setFocused(false)
}}
className={cn(
"group/multi-select relative flex min-h-8 w-full min-w-0 cursor-text items-center gap-1 rounded-lg border border-input bg-transparent py-0.5 pr-1 pl-1 text-sm transition-[color,box-shadow,border-color] outline-none",
"focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50",
"has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20",
"data-disabled:cursor-not-allowed data-disabled:opacity-50",
className,
)}
{...props}
/>
)
}
/** The wrapping row of chips and the input, inside MultiSelectField. */
function MultiSelectChips({ className, ...props }: React.ComponentProps<"div">) {
return <div data-slot="multi-select-chips" className={cn("flex min-w-0 flex-1 flex-wrap items-center gap-1", className)} {...props} />
}
type MultiSelectValueProps<Value> = {
/** Renders one chip; give it a key. */
children: (value: Value, index: number) => React.ReactNode
/** Chips to show while the field is idle. The rest fold into "+N more" until the field has focus. */
max?: number
/** Replaces the default "+N more" chip; gets the values that are folded away. */
overflow?: (hidden: Value[]) => React.ReactNode
}
/** The picked values as chips, in the order they were picked. */
function MultiSelectValue<Value>({ children, max, overflow }: MultiSelectValueProps<Value>) {
const { expanded } = useMultiSelect()
return (
<ComboboxPrimitive.Value>
{(values: Value[]) => {
const fold = max !== undefined && !expanded && values.length > max
const shown = fold ? values.slice(0, max) : values
const hidden = fold ? values.slice(max) : []
return (
<>
{shown.map((value, index) => children(value, index))}
{hidden.length ? (overflow ? overflow(hidden) : <MultiSelectOverflow>+{hidden.length} more</MultiSelectOverflow>) : null}
</>
)
}}
</ComboboxPrimitive.Value>
)
}
type MultiSelectChipProps = Omit<ComboboxPrimitive.Chip.Props, "className"> & {
className?: string
/** The remove button's accessible name, e.g. "Remove Design". */
removeLabel?: string
removable?: boolean
}
function MultiSelectChip({ className, children, removeLabel = "Remove", removable = true, ...props }: MultiSelectChipProps) {
return (
<ComboboxPrimitive.Chip
data-slot="multi-select-chip"
className={cn(
"flex h-6 max-w-full min-w-0 items-center gap-1 rounded-md bg-foreground/10 pl-2 text-xs font-medium text-foreground outline-none focus:ring-2 focus:ring-ring",
removable ? "pr-0.5" : "pr-2",
className,
)}
{...props}
>
{typeof children === "string" ? <span className="truncate">{children}</span> : children}
{removable ? (
<ComboboxPrimitive.ChipRemove
aria-label={removeLabel}
data-slot="multi-select-chip-remove"
className="flex size-5 shrink-0 cursor-default items-center justify-center rounded-sm opacity-60 transition-opacity hover:bg-foreground/10 hover:opacity-100 disabled:pointer-events-none"
>
<XIcon aria-hidden="true" className="size-3" />
</ComboboxPrimitive.ChipRemove>
) : null}
</ComboboxPrimitive.Chip>
)
}
/** The "+N more" chip MultiSelectValue shows when it folds chips away. */
function MultiSelectOverflow({ className, ...props }: React.ComponentProps<"span">) {
return (
<span
data-slot="multi-select-overflow"
className={cn("flex h-6 shrink-0 items-center rounded-md border border-dashed border-border px-1.5 text-xs font-medium text-muted-foreground tabular-nums", className)}
{...props}
/>
)
}
type MultiSelectInputProps = Omit<ComboboxPrimitive.Input.Props, "className"> & { className?: string }
function MultiSelectInput({ className, onKeyDown, ...props }: MultiSelectInputProps) {
const { open, expanded } = useMultiSelect()
return (
<ComboboxPrimitive.Input
data-slot="multi-select-input"
onKeyDown={(event) => {
onKeyDown?.(event)
// The primitive clears every pick on Escape while the list is closed; here Escape only closes it.
if (event.key === "Escape" && !open) event.preventBaseUIHandler()
}}
className={cn(
"h-6 flex-1 bg-transparent px-1.5 text-base outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed md:text-sm",
// Room to type while editing; while idle it squeezes in after the chips instead of taking a row.
expanded ? "min-w-20" : "min-w-0 not-placeholder-shown:px-0",
className,
)}
{...props}
/>
)
}
type MultiSelectButtonProps = Omit<ComboboxPrimitive.Clear.Props, "className"> & { className?: string }
const iconButton =
"flex size-6 shrink-0 cursor-default items-center justify-center rounded-md text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none [&_svg]:size-4"
/** Removes every pick. Shows only while something is picked; reachable with Tab. */
function MultiSelectClear({ className, children, ...props }: MultiSelectButtonProps) {
return (
<ComboboxPrimitive.Clear data-slot="multi-select-clear" aria-label="Clear all" tabIndex={0} className={cn(iconButton, className)} {...props}>
{children ?? <XIcon aria-hidden="true" />}
</ComboboxPrimitive.Clear>
)
}
type MultiSelectTriggerProps = Omit<ComboboxPrimitive.Trigger.Props, "className"> & { className?: string }
/** The chevron that opens and closes the list. */
function MultiSelectTrigger({ className, children, ...props }: MultiSelectTriggerProps) {
return (
<ComboboxPrimitive.Trigger
data-slot="multi-select-trigger"
aria-label="Show options"
className={cn(iconButton, "[&_svg]:transition-transform data-popup-open:[&_svg]:rotate-180", className)}
{...props}
>
{children ?? <ChevronDownIcon aria-hidden="true" />}
</ComboboxPrimitive.Trigger>
)
}
type MultiSelectContentProps = Omit<ComboboxPrimitive.Popup.Props, "className"> & { className?: string } & Pick<
ComboboxPrimitive.Positioner.Props,
"side" | "align" | "sideOffset" | "alignOffset"
>
/** The list's popup, as wide as the field and anchored below it. */
function MultiSelectContent({ className, side = "bottom", sideOffset = 6, align = "start", alignOffset = 0, ...props }: MultiSelectContentProps) {
const { anchorRef } = useMultiSelect()
return (
<ComboboxPrimitive.Portal>
<ComboboxPrimitive.Positioner anchor={anchorRef} side={side} sideOffset={sideOffset} align={align} alignOffset={alignOffset} className="isolate z-50">
<ComboboxPrimitive.Popup
data-slot="multi-select-content"
className={cn(
"group/multi-select-content flex max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) flex-col overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100",
"data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",
className,
)}
{...props}
/>
</ComboboxPrimitive.Positioner>
</ComboboxPrimitive.Portal>
)
}
type MultiSelectListProps = Omit<ComboboxPrimitive.List.Props, "className"> & { className?: string }
function MultiSelectList({ className, ...props }: MultiSelectListProps) {
return (
<ComboboxPrimitive.List
data-slot="multi-select-list"
className={cn("max-h-72 min-h-0 flex-1 scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0", className)}
{...props}
/>
)
}
const itemClass =
"group/multi-select-item relative flex w-full cursor-default items-center gap-2.5 rounded-md px-2 py-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0"
type MultiSelectItemProps = Omit<ComboboxPrimitive.Item.Props, "className"> & { className?: string }
/** An option with a check box that fills when it is picked. */
function MultiSelectItem({ className, children, ...props }: MultiSelectItemProps) {
return (
<ComboboxPrimitive.Item data-slot="multi-select-item" className={cn(itemClass, className)} {...props}>
<span
aria-hidden="true"
data-slot="multi-select-check"
className="flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input text-transparent transition-colors group-data-[selected]/multi-select-item:border-primary group-data-[selected]/multi-select-item:bg-primary group-data-[selected]/multi-select-item:text-primary-foreground"
>
<CheckIcon className="size-3" strokeWidth={3} />
</span>
{children}
</ComboboxPrimitive.Item>
)
}
/** The "Create “…”" row: an option without a check box, for a value that is not in the list yet. */
function MultiSelectCreate({ className, children, ...props }: MultiSelectItemProps) {
return (
<ComboboxPrimitive.Item data-slot="multi-select-create" className={cn(itemClass, className)} {...props}>
<span aria-hidden="true" className="flex size-4 shrink-0 items-center justify-center text-muted-foreground group-data-highlighted/multi-select-item:text-accent-foreground">
<PlusIcon className="size-4" />
</span>
<span className="min-w-0 truncate">{children}</span>
</ComboboxPrimitive.Item>
)
}
type MultiSelectGroupProps = Omit<ComboboxPrimitive.Group.Props, "className"> & { className?: string }
function MultiSelectGroup({ className, ...props }: MultiSelectGroupProps) {
return <ComboboxPrimitive.Group data-slot="multi-select-group" className={cn("not-first:mt-1", className)} {...props} />
}
type MultiSelectGroupLabelProps = Omit<ComboboxPrimitive.GroupLabel.Props, "className"> & { className?: string }
function MultiSelectGroupLabel({ className, ...props }: MultiSelectGroupLabelProps) {
return (
<ComboboxPrimitive.GroupLabel
data-slot="multi-select-group-label"
className={cn("sticky top-0 z-10 -mx-1 bg-popover px-3 pt-2 pb-1 text-xs font-medium text-muted-foreground", className)}
{...props}
/>
)
}
/** Renders a group's items; use inside MultiSelectGroup with a function child. */
const MultiSelectCollection = ComboboxPrimitive.Collection
type MultiSelectEmptyProps = Omit<ComboboxPrimitive.Empty.Props, "className"> & { className?: string }
/** Shows its children only when nothing matches (it stays mounted as a live region). */
function MultiSelectEmpty({ className, ...props }: MultiSelectEmptyProps) {
return (
<ComboboxPrimitive.Empty
data-slot="multi-select-empty"
className={cn("flex flex-col items-center justify-center gap-1 px-4 py-6 text-center text-sm text-muted-foreground empty:p-0", className)}
{...props}
/>
)
}
function MultiSelectSeparator({ className, ...props }: Omit<ComboboxPrimitive.Separator.Props, "className"> & { className?: string }) {
return <ComboboxPrimitive.Separator data-slot="multi-select-separator" className={cn("-mx-1 my-1 h-px bg-border", className)} {...props} />
}
/** A polite live region, e.g. "4 results", for screen readers. Usually with className="sr-only". */
function MultiSelectStatus({ className, ...props }: Omit<ComboboxPrimitive.Status.Props, "className"> & { className?: string }) {
return <ComboboxPrimitive.Status data-slot="multi-select-status" className={className} {...props} />
}
/** A strip under the list for a hint such as "2 of 3 picked". */
function MultiSelectFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="multi-select-footer"
className={cn("flex items-center gap-2 border-t border-border px-3 py-2 text-xs text-muted-foreground", className)}
{...props}
/>
)
}
// ---------------------------------------------------------------------------------------------
// The ready field
type MultiSelectOption = {
value: string
label: string
/** A second line under the label, such as a role or an email. Search matches it too. */
description?: string
/** More words search should match, such as a country code. */
keywords?: string[]
disabled?: boolean
}
type MultiSelectOptionGroup<T extends MultiSelectOption = MultiSelectOption> = { label: string; options: readonly T[] }
const CREATE = Symbol("multi-select-create")
type CreateEntry = MultiSelectOption & { [CREATE]: true }
type Entry<T> = T | CreateEntry
type EntryGroup<T> = { label: string | null; items: Entry<T>[] }
const isCreate = (entry: MultiSelectOption): entry is CreateEntry => CREATE in entry
const isGroup = <T extends MultiSelectOption>(entry: T | MultiSelectOptionGroup<T>): entry is MultiSelectOptionGroup<T> => "options" in entry
const normalize = (text: string) =>
text
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase()
const matches = (option: MultiSelectOption, query: string) =>
!query || [option.label, option.description ?? "", ...(option.keywords ?? [])].some((text) => normalize(text).includes(query))
type InputAriaProps = Pick<React.ComponentProps<"input">, "aria-label" | "aria-labelledby" | "aria-describedby" | "aria-invalid">
type MultiSelectProps<T extends MultiSelectOption> = InputAriaProps & {
/** A flat list, or groups of { label, options }. Options outside a group list first. */
options: readonly (T | MultiSelectOptionGroup<T>)[]
/** The picked option values, when controlled. */
value?: string[]
defaultValue?: string[]
onValueChange?: (value: string[]) => void
/** Shown while nothing is picked. */
placeholder?: string
/** Most picks allowed. Once full, the options not picked are disabled and the list says so. */
max?: number
/** Chips to show while the field is idle; the rest fold into "+N more" until it has focus. */
maxChips?: number
/** Offer "Create “…”" when the typed text matches no option's label. */
creatable?: boolean
/** Called with the typed text when someone creates a value. Return the new option, or nothing to use the text as value and label. */
onCreate?: (label: string) => T | void
/** What the list says when nothing matches. A function gets the typed text. */
emptyMessage?: React.ReactNode | ((query: string) => React.ReactNode)
/** Show a spinner row instead of the options, e.g. while they load from your API. */
loading?: boolean
loadingMessage?: React.ReactNode
/** An option's content after its check box. Defaults to the label with the description under it. */
renderOption?: (option: T) => React.ReactNode
/** A chip's content. Defaults to the label. */
renderChip?: (option: T) => React.ReactNode
chipClassName?: string
/** A strip under the list. With max set it defaults to "N of max picked"; pass null to hide it. */
footer?: React.ReactNode
/** Show the clear-all button while something is picked. */
clearable?: boolean
open?: boolean
onOpenChange?: (open: boolean) => void
disabled?: boolean
required?: boolean
/** Submits each picked value under this name with the form. */
name?: string
/** Goes on the input, for <Label htmlFor>. */
id?: string
className?: string
}
function MultiSelect<T extends MultiSelectOption = MultiSelectOption>({
options,
value: valueProp,
defaultValue,
onValueChange,
placeholder = "Select…",
max,
maxChips,
creatable = false,
onCreate,
emptyMessage = "No matches.",
loading = false,
loadingMessage = "Loading…",
renderOption,
renderChip,
chipClassName,
footer,
clearable = true,
open,
onOpenChange,
disabled,
required,
name,
id,
className,
...aria
}: MultiSelectProps<T>) {
const [valueState, setValueState] = React.useState<string[]>(defaultValue ?? [])
const value = valueProp ?? valueState
const [query, setQuery] = React.useState("")
const [created, setCreated] = React.useState<T[]>([])
const grouped = options.some(isGroup)
const groups = React.useMemo(() => {
const loose = options.filter((o): o is T => !isGroup(o))
const list: { label: string | null; options: readonly T[] }[] = [
...(loose.length || !options.some(isGroup) ? [{ label: null, options: loose }] : []),
...options.filter(isGroup).map((g) => ({ label: g.label, options: g.options })),
]
const known = new Set(list.flatMap((g) => g.options.map((o) => o.value)))
const extra = created.filter((o) => !known.has(o.value))
if (extra.length) {
if (list.length === 1 && list[0].label === null) list[0] = { label: null, options: [...list[0].options, ...extra] }
else list.push({ label: "Added by you", options: extra })
}
return list
}, [options, created])
const byValue = React.useMemo(() => new Map(groups.flatMap((g) => g.options.map((o) => [o.value, o] as const))), [groups])
const selected = React.useMemo(() => value.map((v) => byValue.get(v) ?? ({ value: v, label: v } as T)), [value, byValue])
const full = max !== undefined && value.length >= max
const trimmed = query.trim().replace(/\s+/g, " ")
const q = normalize(trimmed)
const createEntry: CreateEntry | null =
creatable && trimmed && ![...byValue.values()].some((o) => normalize(o.label) === q) ? { value: `\u0000create:${trimmed}`, label: trimmed, [CREATE]: true } : null
const allGroups: EntryGroup<T>[] = groups.map((g) => ({ label: g.label, items: [...g.options] }))
const shownGroups: EntryGroup<T>[] = loading
? []
: groups.map((g) => ({ label: g.label, items: g.options.filter((o) => matches(o, q)) as Entry<T>[] })).filter((g) => g.items.length)
if (createEntry && !loading) {
if (grouped) shownGroups.push({ label: null, items: [createEntry] })
else if (shownGroups.length) shownGroups[0].items.push(createEntry)
else shownGroups.push({ label: null, items: [createEntry] })
}
const shownCount = shownGroups.reduce((n, g) => n + g.items.filter((e) => !isCreate(e)).length, 0)
const setValue = (next: string[]) => {
if (valueProp === undefined) setValueState(next)
onValueChange?.(next)
}
const handleChange = (next: Entry<T>[]) => {
const kept = next.filter((e) => !isCreate(e)).map((e) => e.value)
const create = next.find(isCreate)
if (!create) return setValue(kept)
const made = onCreate?.(create.label) ?? ({ value: create.label, label: create.label } as T)
if (!byValue.has(made.value)) setCreated((list) => [...list, made])
setValue([...kept.filter((v) => v !== made.value), made.value])
}
const renderEntry = (entry: Entry<T>) =>
isCreate(entry) ? (
<MultiSelectCreate key={entry.value} value={entry} disabled={full}>
Create “{entry.label}”
</MultiSelectCreate>
) : (
<MultiSelectItem key={entry.value} value={entry} disabled={entry.disabled || (full && !value.includes(entry.value))}>
{renderOption ? (
renderOption(entry)
) : (
<span className="flex min-w-0 flex-1 flex-col">
<span className="truncate">{entry.label}</span>
{entry.description ? <span className="truncate text-xs text-muted-foreground">{entry.description}</span> : null}
</span>
)}
</MultiSelectItem>
)
const footerContent =
footer !== undefined ? footer : max !== undefined ? (full ? `${max} of ${max} picked. Remove one to pick another.` : `${value.length} of ${max} picked`) : null
return (
<MultiSelectRoot<Entry<T>>
items={grouped ? allGroups : allGroups[0].items}
filteredItems={grouped ? shownGroups : (shownGroups[0]?.items ?? [])}
value={selected}
onValueChange={handleChange}
inputValue={query}
onInputValueChange={setQuery}
isItemEqualToValue={(a, b) => a.value === b.value}
itemToStringLabel={(entry) => entry.label}
itemToStringValue={(entry) => entry.value}
autoHighlight
open={open}
onOpenChange={onOpenChange ? (next) => onOpenChange(next) : undefined}
disabled={disabled}
required={required}
name={name}
id={id}
>
<MultiSelectField className={className}>
<MultiSelectChips>
<MultiSelectValue<Entry<T>>
max={maxChips}
overflow={(hidden) => (
<MultiSelectOverflow title={hidden.map((h) => h.label).join(", ")}>
+{hidden.length} more
</MultiSelectOverflow>
)}
>
{(entry) => (
<MultiSelectChip key={entry.value} removeLabel={`Remove ${entry.label}`} className={chipClassName}>
{renderChip && !isCreate(entry) ? renderChip(entry) : entry.label}
</MultiSelectChip>
)}
</MultiSelectValue>
<MultiSelectInput placeholder={value.length ? undefined : placeholder} {...aria} />
</MultiSelectChips>
{clearable ? <MultiSelectClear /> : null}
<MultiSelectTrigger />
</MultiSelectField>
<MultiSelectContent>
<MultiSelectStatus className="sr-only">{trimmed && !loading ? `${shownCount} ${shownCount === 1 ? "result" : "results"}` : ""}</MultiSelectStatus>
<MultiSelectEmpty>
{loading ? (
<span className="flex items-center gap-2">
<LoaderCircleIcon aria-hidden="true" className="size-4 animate-spin" />
{loadingMessage}
</span>
) : typeof emptyMessage === "function" ? (
emptyMessage(trimmed)
) : (
emptyMessage
)}
</MultiSelectEmpty>
<MultiSelectList>
{grouped
? (group: EntryGroup<T>, index: number) => (
<MultiSelectGroup key={group.label ?? `group-${index}`} items={group.items}>
{group.label ? <MultiSelectGroupLabel>{group.label}</MultiSelectGroupLabel> : null}
<MultiSelectCollection>{(entry: Entry<T>) => renderEntry(entry)}</MultiSelectCollection>
</MultiSelectGroup>
)
: (entry: Entry<T>) => renderEntry(entry)}
</MultiSelectList>
{footerContent ? <MultiSelectFooter aria-live="polite">{footerContent}</MultiSelectFooter> : null}
</MultiSelectContent>
</MultiSelectRoot>
)
}
export {
MultiSelect,
MultiSelectChip,
MultiSelectChips,
MultiSelectClear,
MultiSelectCollection,
MultiSelectContent,
MultiSelectCreate,
MultiSelectEmpty,
MultiSelectField,
MultiSelectFooter,
MultiSelectGroup,
MultiSelectGroupLabel,
MultiSelectInput,
MultiSelectItem,
MultiSelectList,
MultiSelectOverflow,
MultiSelectRoot,
MultiSelectSeparator,
MultiSelectStatus,
MultiSelectTrigger,
MultiSelectValue,
type MultiSelectOption,
type MultiSelectOptionGroup,
type MultiSelectProps,
}