Skip to content
Forms Core Stable

Select

.md

A single-choice dropdown built on a real button and a portalled listbox panel, with full keyboard navigation, typeahead and focus that never leaves the trigger.

Available for Svelte 5, React, and Vue 3.

Preview

Installation

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

Usage

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

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

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

<Select
	sound
	options={frameworks}
	bind:value={framework}
	label="Framework"
	placeholder="Choose a framework"
	class="w-[220px]"
/>

Examples

Basic Usage

Three frameworks, one selected by default.

With FormField

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

Disabled Options

One option unavailable — skipped by keyboard, typeahead and pointer selection.

Placement

The panel anchored on all four sides of the trigger.

Interactive Playground

Props

PropTypeDefaultDescription
options *SelectOption[]-The choices, in order — { value, label, disabled? }.
value string""The selected value, bindable — "" means nothing is selected.
onValueChange (value: string) => void-Called with the new value whenever the selection changes.
placeholder string-Shown in the trigger while nothing is selected.
disabled booleanfalseBlocks opening; excludes the control from form submission.
required booleanfalseMarks the control required (aria-required). No native form-validation enforcement — see the README.
invalid booleanfalseDrives the error border and aria-invalid.
id string-Element id.
name string-Native name. When set, a hidden input carries the value into the form.
label string-Accessible name — for a control with no visible Label next to it.
side "top" | "bottom" | "left" | "right""bottom"Side of the trigger to place the panel on. Flips when it would overflow.
align "start" | "center" | "end""start"Alignment along the trigger's cross axis.
class string-Additional CSS classes, merged onto the trigger.
ref HTMLButtonElement | nullnullBindable reference to the trigger button.
sound booleanfalsePlays open on opening, select on a committed choice and close on a dismissal, once the user has enabled sound