Forms

Multi select

Several choices from a fixed list, kept readable in the field as chips. The list searches as you type and stays open while you tick.

Installation

npx sinaui add multi-select

Examples

Basic

Open it, search, tick as many as you like. Backspace in the field removes the last chip.

  • Astronomy
  • Optics

Choose the collections to include in the catalog.

<script lang="ts">
	import MultiSelect, { type MultiOption } from '#lib/ui/MultiSelect.svelte';

	const fields: MultiOption[] = [
		{ value: 'astronomy', label: 'Astronomy' },
		{ value: 'medicine', label: 'Medicine' },
		{ value: 'mathematics', label: 'Mathematics' },
		{ value: 'optics', label: 'Optics' },
		{ value: 'philosophy', label: 'Philosophy' },
		{ value: 'geography', label: 'Geography' },
		{ value: 'alchemy', label: 'Alchemy' },
		{ value: 'music', label: 'Music theory' }
	];
	let chosen = $state(['astronomy', 'optics']);
</script>

<div class="demo">
	<MultiSelect
		label="Fields of study"
		options={fields}
		bind:value={chosen}
		hint="Choose the collections to include in the catalog."
	/>
</div>

<style>
	.demo {
		inline-size: min(24rem, 100%);
	}
</style>

Up to a limit, in a form

max stops at three; the rest wait until one is removed. With name, each choice is sent with the form.

Sends: nothing yet

<script lang="ts">
	import MultiSelect, { type MultiOption } from '#lib/ui/MultiSelect.svelte';

	const translators: MultiOption[] = [
		{ value: 'hunayn', label: 'Hunayn ibn Ishaq', description: 'Greek and Syriac' },
		{ value: 'thabit', label: 'Thabit ibn Qurra', description: 'Greek, mathematics' },
		{ value: 'qusta', label: 'Qusta ibn Luqa', description: 'Greek, medicine' },
		{ value: 'ishaq', label: 'Ishaq ibn Hunayn', description: 'Greek, philosophy' },
		{ value: 'ibn-muqaffa', label: 'Ibn al-Muqaffa', description: 'Middle Persian' },
		{
			value: 'yahya',
			label: 'Yahya ibn al-Bitriq',
			description: 'Greek, unavailable',
			disabled: true
		}
	];
	let team = $state<string[]>([]);
</script>

<form class="demo" onsubmit={(e) => e.preventDefault()}>
	<MultiSelect
		label="Translators"
		options={translators}
		bind:value={team}
		max={3}
		name="translators"
		placeholder="Choose up to three"
	/>
	<p class="out">Sends: {team.length ? team.join(', ') : 'nothing yet'}</p>
</form>

<style>
	.demo {
		inline-size: min(24rem, 100%);
	}
	.out {
		margin: 0.5rem 0 0;
		color: var(--ui-muted);
		font-size: 0.8125rem;
	}
</style>

Props

PropTypeDefault
labelstring (required)
options{ value, label, description?, disabled? }[]
valuestring[] (bindable)[]
maxnumber
placeholderstring'Choose…'
namestring: sends each choice with the form
hint, errorstring
disabledbooleanfalse
searchLabel, emptystring'Search', 'No matches'

Keyboard

KeyDoes
↓ Enter SpaceOpens the list, with focus in its search box
↑ ↓Moves through the options
EnterTicks or unticks the highlighted option; the list stays open
EscapeCloses the list
BackspaceIn the closed field, removes the last choice

Accessibility

  • The field is a combobox for a multi-select listbox; each option says whether it's chosen.
  • Adding and removing are announced with the running count.
  • Each chip's remove button is named after it; "Remove all" clears the field.
  • With reduced motion, chips appear and leave without scaling.
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Menubar
Navigation menu
Pagination
Sidebar layout
Stepper
Tabs
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
File explorer
Messaging
Notifications
Settings
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme