Skip to content

MultiSelect

MultiSelect

Basic Usage

Searchable

Type to filter options

With Descriptions

Max Selection (2)

Limited to 2 items. Button disables when limit reached.

Layout Options

Right (default)

Left

Below

Disabled

import { MultiSelect, type MultiSelectOption } from "@f0rbit/ui";
const options: MultiSelectOption[] = [
{ value: "apple", label: "Apple" },
{ value: "banana", label: "Banana" },
{ value: "cherry", label: "Cherry" },
];
const [selected, setSelected] = createSignal<string[]>([]);
<MultiSelect
options={options}
value={selected()}
onChange={setSelected}
placeholder="Select fruits..."
/>
PropTypeDefaultDescription
optionsMultiSelectOption[]Available options to select from
valueT[]Array of selected values
onChange(value: T[]) => voidCallback when selection changes
placeholderstring"Nothing selected"Placeholder when empty
addLabelstring"Add"Label for the add button
doneLabelstring"Done"Label for the done button
emptyMessagestring"No options available"Message when no options match
searchablebooleanfalseEnable search filtering
searchPlaceholderstring"Search..."Search input placeholder
maxnumberMaximum number of selections
disabledbooleanfalseDisable the select
renderBadge(option: MultiSelectOption) => JSX.ElementCustom badge rendering
renderOption(option: MultiSelectOption) => JSX.ElementCustom option rendering

Enable search filtering with searchable:

<MultiSelect
options={options}
value={selected()}
onChange={setSelected}
searchable
searchPlaceholder="Search options..."
/>

Add descriptions to options for more context:

const roles: MultiSelectOption[] = [
{ value: "admin", label: "Admin", description: "Full system access" },
{ value: "editor", label: "Editor", description: "Can edit content" },
{ value: "viewer", label: "Viewer", description: "Read-only access" },
];
<MultiSelect
options={roles}
value={selected()}
onChange={setSelected}
/>

Individual options can be disabled:

const options: MultiSelectOption[] = [
{ value: "available", label: "Available" },
{ value: "unavailable", label: "Unavailable", disabled: true },
];

Limit the number of selections with max:

<MultiSelect
options={options}
value={selected()}
onChange={setSelected}
max={3}
placeholder="Select up to 3..."
/>

Customize the Add/Done button labels:

<MultiSelect
options={options}
value={selected()}
onChange={setSelected}
addLabel="Assign"
doneLabel="Close"
/>

Customize how selected items appear with renderBadge:

<MultiSelect
options={tags}
value={selected()}
onChange={setSelected}
renderBadge={(opt) => (
<Badge variant={opt.value === "urgent" ? "error" : "default"}>
{opt.label}
</Badge>
)}
/>

Customize dropdown options with renderOption:

<MultiSelect
options={users}
value={selected()}
onChange={setSelected}
renderOption={(opt) => (
<div class="row">
<Avatar src={opt.data.avatar} />
<span>{opt.label}</span>
</div>
)}
/>

Customize the empty dropdown message:

<MultiSelect
options={[]}
value={[]}
onChange={() => {}}
emptyMessage="No options available"
/>
<MultiSelect
options={availableTags}
value={selectedTags()}
onChange={setSelectedTags}
searchable
placeholder="Add tags..."
addLabel="Add Tags"
/>
<MultiSelect
options={roles}
value={userRoles()}
onChange={setUserRoles}
placeholder="Assign roles..."
max={3}
/>
<MultiSelect
options={categories}
value={activeFilters()}
onChange={setActiveFilters}
searchable
placeholder="Filter by category..."
/>