logo-icon
STWUI

Select



You're doing it wrong!


svelte
<script lang="ts">
	import { Select } from 'stwui';

	const email = "svg-path";
	const options = ['Option 1', 'Option 2', 'Option 3'];

	let value: string | undefined;
	let error: string | undefined = "You're doing it wrong!";
	$: if (value && value.length > 0) {
		error = undefined;
	} else {
		error = "You're doing it wrong!";
	}
</script>

<Select name="select-1" placeholder="Basic">
	<Select.Options slot="options">
		{#each options as option}
			<Select.Options.Option {option} />
		{/each}
	</Select.Options>
</Select>

<Select name="select-2">
	<Select.Label slot="label">Label</Select.Label>
	<Select.Leading slot="leading" data={email} />
	<Select.Options slot="options">
		{#each options as option}
			<Select.Options.Option {option} />
		{/each}
	</Select.Options>
</Select>

<Select name="select-3" {error} bind:value>
	<Select.Label slot="label">Label</Select.Label>
	<Select.Leading slot="leading" data={email} />
	<Select.Options slot="options">
		{#each options as option}
			<Select.Options.Option {option} />
		{/each}
	</Select.Options>
</Select>

Select Props

name string
error string | undefined
placeholder string | undefined
value string | undefined
visible boolean false

Select Slots

label <Select.Label slot="label" />
leading <Select.Leading slot="leading" />
options <Select.Options slot="options" />

Select.Label Slots

default

Select.Leading Props

data string (IconData)
viewBox string 0 0 24 24
size string 24px
width string 24px
height string 24px
color string currentColor
stroke string | undefined
fill string currentColor

Select.Options Slots

default

Select.Options.Option Props

option string