Saltearse al contenido

Option

Esta página aún no está disponible en tu idioma.

The Option component is a field to select an option from a list of options. It can be used to select a single option or multiple options.

<script lang="ts">
import { Option } from "@tuentyfaiv/svelte-form";
import type { OptionItem } from "@tuentyfaiv/svelte-form";
const options: OptionItem[] = [
{ value: "1", label: "Option 1" },
{ value: "2", label: "Option 2" },
{ value: "3", label: "Option 3" },
];
</script>
<Option name="name" label="Options" {options} />
<!-- Or -->
<Option name="name" label="Options" {options} >
This is a custom label
<span slot="option" let:option>
Customized option label
{option.label}
</span>
<span slot="content">
Add some content
</span>
<svelte:fragment slot="error" let:error>
{formatError(error)}
</svelte:fragment>
</Option>

Single

Select your hobby:

Multiple

Select your hobbies:

Disabled

Select your hobby: