Combobox
Matching uses fuse.js against each item's value and label, so small typos still match. Lower the trigger's threshold (default 0.28) to make matching stricter.
Installation
Copy the command below and run it in your terminal.
Usage
Bind value on Combobox.Root. Every item needs a value and a label. The trigger is a text field that
shows the selected label, so it takes a placeholder instead of children.
Examples
Basic usage
Input search
Set appearance="input" to style the
trigger as an input. It opens on focus or typing, and shows a clear button once it has a
query or selection. It has no chevron; pass a trailing snippet to show an icon while the field is empty.
Scrollable
Add a max-h-* class to Combobox.Content to cap the menu height. Longer result lists scroll inside it.
Anatomy
Combobox.Root - Holds the selected value and open state.
Combobox.Content - Renders the menu and, optionally, its search field.
Combobox.Trigger - Shows the selection and takes the search text.
Combobox.Results - Lists matching items.
Combobox.Item - Defines a selectable item.
Combobox.Label - Labels a group of items in the menu.
<script lang="ts"> import * as Combobox from '@sivir-ui/svelte/components/combobox'; const items = [ { value: 'option-1', label: 'Option 1' }, { value: 'option-2', label: 'Option 2' }, { value: 'option-3', label: 'Option 3' } ]; </script> <div class="w-[280px]"> <Combobox.Root> <Combobox.Trigger placeholder="Select an option" class="w-full" /> <Combobox.Content> <Combobox.Results> {#each items as item (item.value)} <Combobox.Item value={item.value} label={item.label} callback={() => {}} /> {/each} </Combobox.Results> </Combobox.Content> </Combobox.Root> </div>