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} >
This is a custom label
<svelte:fragment let:iten slot="item">
Customized item
{item.label}
</svelte:fragment>
<i class="icon" slot="remove">🧨</i>
<i class="icon" slot="clear">🗑</i>
<i class="icon" slot="arrow">🔽</i>
<svelte:fragment slot="option" let:option let:selected>
Customized option
{option.label}
{selected && " (selected)"}
</svelte:fragment>
<span slot="empty">
Customized empty
</span>
<svelte:fragment slot="error" let:error>
{formatError(error)}
</svelte:fragment>
</Select>

Single

Multiple

Fixed options

Non searchable

Multiple non searchable

Non clearable

Disabled