Select
A dropdown component that allows users to select one or more options from a list.
Anatomy
<script>
import {
Select,
SelectRoot,
SelectTrigger,
SelectValue,
SelectAvatarValue,
SelectContent,
SelectItem,
SelectItemGroup,
SelectLabel,
SelectClearTrigger,
SelectIndicator,
} from "@saas-ui/svelte/components/select";
</script>
<Select.Root items={frameworks}>
<Select.Label>Framework</Select.Label>
<Select.Trigger>
<Select.Value placeholder="Select a framework" />
</Select.Trigger>
<Select.Content>
{#each frameworks as item}
<Select.Item {item}>
{item.label}
<Select.Indicator />
</Select.Item>
{/each}
</Select.Content>
</Select.Root>Examples
Avatar Select Accessibility
Select.AvatarValue to display avatars in the selected value.
<Box class="w-60">
<Select.Root
collection={members}
defaultValue={["jessica_jones"]}
size="sm"
positioning={{ sameWidth: true }}
>
<Select.Label>Select member</Select.Label>
<Select.Trigger>
<Select.AvatarValue placeholder="Select member" />
</Select.Trigger>
<Select.Content>
{#each members.items as item}
<Select.Item {item} class="justify-start">
<Avatar name={item.name} src={item.avatar} size="xs" />
{item.name}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</Box> Basic Accessibility
<Box class="w-80">
<Select.Root collection={frameworks} size="sm">
<Select.Label>Select framework</Select.Label>
<Select.Trigger>
<Select.Value placeholder="Select movie" />
</Select.Trigger>
<Select.Content>
{#each frameworks.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</Box> Clear Trigger Accessibility
clearable prop on trigger to allow clearing the selection.
<Box class="w-80">
<Select.Root
collection={animeMovies}
defaultValue={["spirited_away"]}
size="sm"
>
<Select.Label>Select fav. anime</Select.Label>
<Select.Trigger clearable>
<Select.Value placeholder="Select movie" />
</Select.Trigger>
<Select.Content>
{#each animeMovies.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</Box> Colours Accessibility
colour prop to change the colour of the select.
<HStack align="start" gap={4} class="flex-wrap">
{#each colours as colour}
<VStack gap={2} class="items-center">
<Text size="xs">{colour}</Text>
<Select.Root collection={frameworks} {colour} class="w-40">
<Select.Trigger aria-label="Select framework">
<Select.Value placeholder="Select" />
</Select.Trigger>
<Select.Content>
{#each frameworks.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</VStack>
{/each}
</HStack> Disabled Accessibility
disabled prop to disable the select.
<Box class="w-80">
<Select.Root collection={frameworks} disabled size="sm">
<Select.Label>Select framework</Select.Label>
<Select.Trigger>
<Select.Value placeholder="Select movie" />
</Select.Trigger>
<Select.Content>
{#each frameworks.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</Box> In Popover Accessibility
<Popover.Root size="xs">
<Popover.Trigger>
{#snippet children({ props })}
<Button variant="outline" size="sm" {...props()}>
Select in Popover
</Button>
{/snippet}
</Popover.Trigger>
<Popover.Content>
<Popover.Header>Select in Popover</Popover.Header>
<Popover.Body>
<Select.Root
collection={frameworks}
size="sm"
positioning={{ sameWidth: true, placement: "bottom" }}
>
<Select.Trigger aria-label="Select framework">
<Select.Value placeholder="Select" />
</Select.Trigger>
<Select.Content portal={false} class="w-full">
{#each frameworks.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</Popover.Body>
</Popover.Content>
</Popover.Root> Invalid Accessibility
Field.Root with invalid prop to show error state.
<Box class="w-80">
<Field.Root invalid>
<Select.Root collection={frameworks} size="sm">
<Select.Label>Select framework</Select.Label>
<Select.Trigger>
<Select.Value placeholder="Select movie" />
</Select.Trigger>
<Select.Content>
{#each frameworks.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
<Field.ErrorText>This is an error</Field.ErrorText>
</Field.Root>
</Box> Option Group Accessibility
Select.ItemGroup for better organization.
<Box class="w-80">
<Select.Root collection={groupedItems} size="sm">
<Select.Label>Select framework</Select.Label>
<Select.Trigger>
<Select.Value placeholder="Select movie" />
</Select.Trigger>
<Select.Content>
{#each getCategories(groupedItems) as category}
<Select.ItemGroup label={category.group}>
{#each category.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.ItemGroup>
{/each}
</Select.Content>
</Select.Root>
</Box> Overflow Accessibility
<Box class="w-60">
<Select.Root collection={animeMovies} size="sm">
<Select.Label>Select anime</Select.Label>
<Select.Trigger>
<Select.Value placeholder="Select movie" />
</Select.Trigger>
<Select.Content>
{#each animeMovies.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</Box> Positioning Accessibility
positioning prop to control dropdown placement.
<Box class="w-80">
<Select.Root
collection={frameworks}
size="sm"
positioning={{ placement: "top", flip: false }}
>
<Select.Label>Select framework</Select.Label>
<Select.Trigger>
<Select.Value placeholder="Select movie" />
</Select.Trigger>
<Select.Content>
{#each frameworks.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</Box> Sizes Accessibility
size prop to change the size of the select.
<VStack gap={5} class="w-80">
{#each selectSizes as size}
<Select.Root collection={frameworks} {size}>
<Select.Label>size = {size}</Select.Label>
<Select.Trigger>
<Select.Value placeholder="Select movie" />
</Select.Trigger>
<Select.Content>
{#each frameworks.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
{/each}
</VStack> Variants Accessibility
variant prop to change the visual style of the select.
<VStack gap={5} class="w-80">
{#each selectVariants as variant}
<Select.Root collection={frameworks} {variant}>
<Select.Label>Select framework - {variant}</Select.Label>
<Select.Trigger>
<Select.Value placeholder="Select movie" />
</Select.Trigger>
<Select.Content>
{#each frameworks.items as item}
<Select.Item {item}>
{item.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
{/each}
</VStack>Props
Select.Root
The root container component for the select.
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | - | The select content. |
collection | ListCollection<T> | - | The collection of items to display. |
id | string | - | The unique identifier for the select. If not provided, a unique ID will be auto-generated. |
size | "xs" | "sm" | "md" | "lg" | "md" | The size of the select. |
variant | "outline" | "subtle" | "outline" | The visual variant of the select trigger. |
colour | ColourName | "indigo" | The colour palette for highlighted items. |
class | string | - | Additional CSS classes to apply. |
Select.Trigger
The trigger button that opens the select dropdown.
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | - | The trigger content. If not provided, renders value and indicator. |
class | string | - | Additional CSS classes to apply. |
clearable | boolean | false | Whether to show a clear button when a value is selected. |
Select.Content
The dropdown content container for select items.
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | - | The select content. |
class | string | - | Additional CSS classes to apply. |
portal | boolean | true | Whether to render the select content in a portal. |
Select.Item
An individual selectable item in the dropdown.
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | - | The select item content. |
class | string | - | Additional CSS classes to apply. |
showIndicator | boolean | true | Whether to show the check indicator when selected. |
Select.ItemGroup
A group of related select items with an optional label.
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | - | The group content (items). |
label | string | - | The group label text. |
class | string | - | Additional CSS classes to apply. |
Select.Label
A label for the select component.
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | - | The label content. |
class | string | - | Additional CSS classes to apply. |
Select.Value
Displays the currently selected value in the trigger.
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet<[items: any[]]> | - | Custom render snippet for the selected value. Receives the selected items array. |
prefix | Snippet<[items: any[]]> | - | Prefix snippet rendered before the value text. Receives the selected items array. |
class | string | - | Additional CSS classes to apply. |
placeholder | string | "Select an option" | Placeholder text when no value is selected. |
valueKey | string | - | Property key to get the display value from the selected item. If not set, uses the default item string representation. |
Select.Indicator
The dropdown indicator icon (typically a caret/chevron).
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | - | Custom icon for the indicator. |
class | string | - | Additional CSS classes to apply. |
Select.ClearTrigger
A button to clear the current selection.
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | - | Custom icon or content for the clear trigger. |
class | string | - | Additional CSS classes to apply. |
Select.AvatarValue
Displays the selected value with an avatar image.
| Prop | Type | Default | Description |
|---|---|---|---|
class | string | - | Additional CSS classes to apply. |
placeholder | string | "Select an option" | Placeholder text when no value is selected. |
avatarKey | string | "avatar" | Property key to get the avatar src from the selected item. |
nameKey | string | "name" | Property key to get the name/label from the selected item. |
avatarSize | number | 20 | Size of the avatar in pixels. |