Skip to content

Select

You can use the Select component to render a select input. This component is for single and multiple select inputs.

By default has enabled searchable, clearable and autoselect options.

<script lang="ts">
import { Select } from "@tuentyfaiv/svelte-form";
import type { SelectOption } from "@tuentyfaiv/svelte-form";
const options: SelectOption[] = [
{ value: "1", label: "Option 1" },
{ value: "2", label: "Option 2" },
{ value: "3", label: "Option 3" },
];
</script>
<Select name="name" label="Options" {options} />
<!-- Or -->
<Select name="name" label="Options" {options} >
Custom label, Options
<img src="/icon-clear.svg" alt="clear options" slot="clear" />
<img src="/icon-arrow.svg" alt="show/hide options" slot="arrow" />
<p slot="option" let:option>
Customized option
{option.label}
</p>
<span slot="empty">
Customized empty
</span>
<span slot="error" let:error>
{formatError(error)}
</span>
</Select>

Single

Multiple

Fixed options

Non searchable

Multiple non searchable

Non clearable

Disabled