Skip to content
Forms Core Stable

Combobox

.md

A single-choice text field over a closed set of options — typing filters a portalled listbox, and a value outside the list can never be selected.

Available for Svelte 5, React, and Vue 3.

Preview

Installation

pnpm add fancy-ui-svelte
import { Combobox } from "fancy-ui-svelte";

Usage

svelte
<script lang="ts">
	import { Combobox } from "fancy-ui-svelte";

	const frameworks = [
		{ value: "svelte-5", label: "Svelte 5" },
		{ value: "sveltekit", label: "SvelteKit" },
		{ value: "react", label: "React" },
		{ value: "vue", label: "Vue" },
	];

	let framework = $state("");
</script>

<Combobox
	sound
	options={frameworks}
	bind:value={framework}
	label="Framework"
	placeholder="Search…"
/>

Examples

Basic Usage

Four frameworks, filtered by typing.

Custom Filter

Matches by value prefix instead of the label — shows the highlight degrading gracefully when the match isn't a literal label substring.

With FormField

Wrapped in FormField — required and the error message driven by context.

Props

PropTypeDefaultDescription
options *ComboboxOption[]-The closed set of selectable options.
value string""The selected option's value, bindable — "" means nothing is selected.
onValueChange (value: string) => void-Called whenever the selection commits.
placeholder string-Shown while the field is empty and nothing is selected.
disabled booleanfalseBlocks focus and typing; excluded from form submission.
required booleanfalseNative required, on the visible field.
invalid booleanfalseDrives the error border and aria-invalid.
id string-Element id.
name string-Native name — submitted via a hidden input carrying value, not the visible label.
label string-Accessible name — for a control with no visible Label next to it.
filter (option: ComboboxOption, query: string) => boolean-Matches an option against the current query. Default: case-insensitive substring on label.
emptyMessage string"No results"Shown in the panel when no option matches the current query.
class string-Additional CSS classes.
ref HTMLInputElement | nullnullBindable reference to the input element.
sound booleanfalsePlays the select cue when an option is committed, once the user has enabled sound