SpecOS SpecOS icon Styleguide

Combobox

A searchable dropdown component that supports icons for both the main input and individual options.

Import

import Combobox from "$lib/components/Combobox.svelte";

Basic Example with Icons

<!-- Example with icons -->
<Combobox
  items={[
    { value: "lock", label: "Lock", icon: "/icons/Lock.svg" },
    { value: "visible", label: "Visible", icon: "/icons/Visible.svg" },
    { value: "star", label: "Star", icon: "/icons/Star.svg" }
  ]}
  mainIcon="/icons/Thunder.svg"
  placeholder="Select an option"
/>

Properties

items
Type
Array<{ value: string; label: string; icon?: string; }>
Default: []
Array of items to display in the combobox. Each item can optionally include an icon path.
inputValue
Type
string
Default: ""
The current value of the input field.
touchedInput
Type
boolean
Default: false
Whether the input has been interacted with.
placeholder
Type
string
Default: "Select an option"
Placeholder text for the input field.
mainIcon
Type
string
Default: undefined
Default icon to show in the input field. Will be replaced by selected item's icon if available.
class_name
Type
string
Default: ""
Additional classes to apply to the input field.