Skip to content

Option

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} >
Custom label, Options
<p slot="option" let:option>
Customized option label
{option.label}
</p>
<span slot="content">
Add some content
</span>
<span slot="error" let:error>
{formatError(error)}
</span>
</Option>

Single

Select your hobby:

Multiple

Select your hobbies:

Disabled

Select your hobby: