value string is stored in client state, accessible via .rx.
Basic Usage
ASelect is a container — use the with block to add SelectOption children. Each option needs a value (what gets stored) and a label (what the user sees):
Pre-selected Option
Mark an option asselected=True to have it chosen when the component first renders:
Sizes
Selects come in two sizes. The"sm" variant is useful when space is tight or when embedding a select alongside other compact controls:
With Label
Pair aSelect with a Label in a Column for a standard form field pattern:
Disabled State
Disabled Options
Individual options can be disabled while the rest of the dropdown remains interactive. Disabled options appear dimmed and cannot be selected:Invalid State
Setinvalid=True to flag a select with error styling. Pair it with a Label in a form layout to signal that a selection is required or incorrect:
Option Groups
Organize long option lists into labeled sections withSelectGroup and SelectLabel. Use SelectSeparator to add visual dividers between groups:
Reading the Value
Use.rx to get a reactive reference to the selected option’s value string. When the user picks an option, anything bound to .rx updates automatically:
Pick an option and the text updates instantly. The .rx reference holds the value string of whichever option is selected — "magrathea", "betelgeuse", etc. — not the display label.
Actions
Theon_change parameter fires actions when the selection changes. Inside the action, $event holds the newly selected value string:
This is different from .rx — here we’re transforming the value before storing it (prepending “You chose: ”). For simple “show the current selection” cases, .rx is the better approach.
API Reference
Select Parameters
Placeholder text shown when no option is selected.
State key for the selected value. Auto-generated if not provided.
Select size:
"default", "sm".Which side of the trigger the dropdown appears on:
"top", "right", "bottom", "left".Alignment of the dropdown relative to the trigger:
"start", "center", "end".Whether the select is non-interactive.
Whether a selection is required for form submission.
Whether the select shows error styling (red border).
Action(s) to execute when the selection changes.
$event is the value string of the selected option.Additional Tailwind CSS classes.
SelectGroup Parameters
Additional Tailwind CSS classes.
SelectSeparator Parameters
Additional Tailwind CSS classes.
SelectOption Parameters
The value stored in state when this option is selected.
Display text shown to the user.
Whether this option is initially selected.
Whether this option is non-interactive.
Additional Tailwind CSS classes.
Protocol Reference
Select
SelectGroup
SelectLabel
SelectSeparator
SelectOption