Select
Displays a list of options for the user to pick from—triggered by a button.
Select follows the Select-Only Combobox WAI-ARIA design pattern.
Use Field.Select (Field) when a native <select> is enough, Select for a custom-styled dropdown without typing, and Combobox when users need to type to filter options.
Selected: none
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Select } from '@leve-ui/select';
import { LuCheck, LuChevronDown } from '@qwikest/icons/lucide';
import styles from './default.css?inline';
const FRUITS = [
{ value: 'apple', label: 'Apple' },
{ value: 'banana', label: 'Banana' },
{ value: 'blueberry', label: 'Blueberry' },
{ value: 'cherry', label: 'Cherry' },
{ value: 'grape', label: 'Grape' },
{ value: 'lemon', label: 'Lemon', disabled: true },
{ value: 'orange', label: 'Orange' },
{ value: 'peach', label: 'Peach' },
];
export default component$(() => {
useStyles$(styles);
const value = useSignal<string | null>(null);
return (
<div class="select-default">
<Select.Root bind:value={value} class="select-default-root">
<Select.Label class="select-default-label">Fruit</Select.Label>
<Select.Trigger class="select-default-trigger">
<Select.Value placeholder="Select a fruit" class="select-default-value" />
<LuChevronDown aria-hidden="true" class="select-default-icon" />
</Select.Trigger>
<Select.Content sideOffset={4} class="select-default-content">
<Select.List>
{FRUITS.map((fruit) => (
<Select.Item
key={fruit.value}
value={fruit.value}
disabled={fruit.disabled}
class="select-default-item"
>
<Select.ItemText>{fruit.label}</Select.ItemText>
<Select.ItemIndicator class="select-default-indicator">
<LuCheck aria-hidden="true" class="select-default-icon" />
</Select.ItemIndicator>
</Select.Item>
))}
</Select.List>
</Select.Content>
</Select.Root>
<p class="select-default-status">Selected: {value.value ?? 'none'}</p>
</div>
);
});.select-default {
display: flex;
flex-direction: column;
gap: 12px;
font-family: inherit;
}
.select-default-root {
display: flex;
flex-direction: column;
gap: 6px;
width: 240px;
}
.select-default-label {
font-size: 14px;
font-weight: 500;
color: light-dark(#0f172a, #ffffff);
}
.select-default-trigger {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
width: 100%;
padding: 8px 10px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font: inherit;
font-size: 14px;
cursor: pointer;
text-align: left;
}
.select-default-trigger:hover {
background: light-dark(#f1f5f9, #ffffff14);
}
.select-default-trigger:focus-visible {
outline: 2px solid #009dfd;
outline-offset: 2px;
}
.select-default-value[data-placeholder] {
color: light-dark(#475569, #c9ddf0);
}
.select-default-icon {
flex-shrink: 0;
width: 16px;
height: 16px;
}
/* The Content is a popover in the top layer; the library sets its position */
.select-default-content {
box-sizing: border-box;
width: var(--leve-select-anchor-width);
max-height: min(240px, var(--leve-select-available-height));
overflow-y: auto;
padding: 4px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font-family: inherit;
box-shadow: 0 8px 24px rgb(15 23 42 / 0.18);
}
.select-default-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 8px;
border-radius: 4px;
font-size: 14px;
cursor: default;
}
/* Arrow keys, typeahead, and pointer hover move the highlight while focus stays on Trigger */
.select-default-item[data-highlighted] {
background: #009dfd;
color: #ffffff;
}
.select-default-item[data-disabled] {
opacity: 0.5;
cursor: not-allowed;
}
.select-default-indicator {
display: inline-flex;
}
.select-default-indicator[hidden] {
display: none;
}
.select-default-status {
margin: 0;
font-size: 14px;
color: light-dark(#475569, #c9ddf0);
}Installation#
Install the individual package, or use @leve-ui/core to get every component at once:
pnpm add @leve-ui/selectnpm install @leve-ui/selectyarn add @leve-ui/selectbun add @leve-ui/selectpnpm add @leve-ui/corenpm install @leve-ui/coreyarn add @leve-ui/corebun add @leve-ui/coreAnatomy#
import { Select } from '@leve-ui/select'; // or '@leve-ui/core'
<Select.Root>
<Select.Label />
<Select.Trigger>
<Select.Value />
</Select.Trigger>
<Select.HiddenInput />
<Select.Content>
<Select.List>
<Select.Item>
<Select.ItemText />
<Select.ItemIndicator />
</Select.Item>
<Select.Group>
<Select.GroupLabel />
<Select.Item />
</Select.Group>
</Select.List>
</Select.Content>
</Select.Root>
| Part | Element | Description |
|---|---|---|
Select.Root | <div> | Wraps the parts and holds the selected value and open state. |
Select.Label | <label> | The label for the trigger and the accessible name of the listbox. |
Select.Trigger | <button> | Button with role="combobox" that toggles the listbox. Focus stays here. |
Select.Value | <span> | Displays the selected option's text or a placeholder. |
Select.HiddenInput | <input> | Optional. Submits the selected value with a native <form>. |
Select.Content | <div> | The popup, a popover="manual" element in the top layer. |
Select.List | <div> | The listbox (role="listbox"). |
Select.Item | <div> | An option (role="option"). |
Select.ItemText | <span> | The text displayed in Select.Value when the option is selected. |
Select.ItemIndicator | <span> | The check mark of the selected option, hidden otherwise. |
Select.Group | <div> | A group of options, named by its GroupLabel. |
Select.GroupLabel | <div> | The name of a group. Not selectable. |
Examples#
Groups and Looping#
Select.Group and Select.GroupLabel organize options into labeled groups. With loop, arrow keys wrap between the first and last options.
import { component$, useStyles$ } from '@builder.io/qwik';
import { Select } from '@leve-ui/select';
import { LuCheck, LuChevronDown } from '@qwikest/icons/lucide';
import styles from './grouped.css?inline';
const TIMEZONES = [
{ region: 'Americas', zones: ['New York', 'Chicago', 'Los Angeles'] },
{ region: 'Europe', zones: ['London', 'Paris', 'Berlin'] },
{ region: 'Asia', zones: ['Tokyo', 'Seoul', 'Singapore'] },
];
export default component$(() => {
useStyles$(styles);
return (
<Select.Root loop class="select-grouped">
<Select.Label class="select-grouped-label">Time zone</Select.Label>
<Select.Trigger class="select-grouped-trigger">
<Select.Value placeholder="Select a time zone" class="select-grouped-value" />
<LuChevronDown aria-hidden="true" class="select-grouped-icon" />
</Select.Trigger>
<Select.Content sideOffset={4} class="select-grouped-content">
<Select.List>
{TIMEZONES.map((group) => (
<Select.Group key={group.region}>
<Select.GroupLabel class="select-grouped-group-label">
{group.region}
</Select.GroupLabel>
{group.zones.map((zone) => (
<Select.Item key={zone} value={zone} class="select-grouped-item">
<Select.ItemText>{zone}</Select.ItemText>
<Select.ItemIndicator class="select-grouped-indicator">
<LuCheck aria-hidden="true" class="select-grouped-icon" />
</Select.ItemIndicator>
</Select.Item>
))}
</Select.Group>
))}
</Select.List>
</Select.Content>
</Select.Root>
);
});.select-grouped {
display: flex;
flex-direction: column;
gap: 6px;
width: 240px;
font-family: inherit;
}
.select-grouped-label {
font-size: 14px;
font-weight: 500;
color: light-dark(#0f172a, #ffffff);
}
.select-grouped-trigger {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
width: 100%;
padding: 8px 10px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font: inherit;
font-size: 14px;
cursor: pointer;
text-align: left;
}
.select-grouped-trigger:hover {
background: light-dark(#f1f5f9, #ffffff14);
}
.select-grouped-trigger:focus-visible {
outline: 2px solid #009dfd;
outline-offset: 2px;
}
.select-grouped-value[data-placeholder] {
color: light-dark(#475569, #c9ddf0);
}
.select-grouped-icon {
flex-shrink: 0;
width: 16px;
height: 16px;
}
/* The Content is a popover in the top layer; the library sets its position */
.select-grouped-content {
box-sizing: border-box;
width: var(--leve-select-anchor-width);
max-height: min(240px, var(--leve-select-available-height));
overflow-y: auto;
padding: 4px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font-family: inherit;
box-shadow: 0 8px 24px rgb(15 23 42 / 0.18);
}
.select-grouped-group-label {
padding: 6px 8px 2px;
font-size: 12px;
font-weight: 600;
color: light-dark(#475569, #c9ddf0);
}
.select-grouped-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 8px;
border-radius: 4px;
font-size: 14px;
cursor: default;
}
.select-grouped-item[data-highlighted] {
background: #009dfd;
color: #ffffff;
}
.select-grouped-indicator {
display: inline-flex;
}
.select-grouped-indicator[hidden] {
display: none;
}Disabled#
disabled on Select.Root prevents opening and disables Select.Trigger and Select.HiddenInput.
import { component$, useStyles$ } from '@builder.io/qwik';
import { Select } from '@leve-ui/select';
import { LuCheck, LuChevronDown } from '@qwikest/icons/lucide';
import styles from './disabled.css?inline';
export default component$(() => {
useStyles$(styles);
return (
<Select.Root disabled defaultValue="starter" class="select-disabled">
<Select.Label class="select-disabled-label">Plan</Select.Label>
<Select.Trigger class="select-disabled-trigger">
<Select.Value placeholder="Choose a plan" />
<LuChevronDown aria-hidden="true" class="select-disabled-icon" />
</Select.Trigger>
<Select.Content sideOffset={4} class="select-disabled-content">
<Select.List>
<Select.Item value="free" class="select-disabled-item">
<Select.ItemText>Free</Select.ItemText>
<Select.ItemIndicator class="select-disabled-indicator">
<LuCheck aria-hidden="true" class="select-disabled-icon" />
</Select.ItemIndicator>
</Select.Item>
<Select.Item value="starter" class="select-disabled-item">
<Select.ItemText>Starter</Select.ItemText>
<Select.ItemIndicator class="select-disabled-indicator">
<LuCheck aria-hidden="true" class="select-disabled-icon" />
</Select.ItemIndicator>
</Select.Item>
<Select.Item value="pro" class="select-disabled-item">
<Select.ItemText>Pro</Select.ItemText>
<Select.ItemIndicator class="select-disabled-indicator">
<LuCheck aria-hidden="true" class="select-disabled-icon" />
</Select.ItemIndicator>
</Select.Item>
</Select.List>
</Select.Content>
</Select.Root>
);
});.select-disabled {
display: flex;
flex-direction: column;
gap: 6px;
width: 240px;
font-family: inherit;
}
.select-disabled-label {
font-size: 14px;
font-weight: 500;
color: light-dark(#0f172a, #ffffff);
}
.select-disabled-label[data-disabled] {
opacity: 0.5;
}
.select-disabled-trigger {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
width: 100%;
padding: 8px 10px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font: inherit;
font-size: 14px;
text-align: left;
}
.select-disabled-trigger:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.select-disabled-icon {
flex-shrink: 0;
width: 16px;
height: 16px;
}
.select-disabled-content {
box-sizing: border-box;
width: var(--leve-select-anchor-width);
padding: 4px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font-family: inherit;
}
.select-disabled-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 8px;
border-radius: 4px;
font-size: 14px;
}
.select-disabled-indicator {
display: inline-flex;
}
.select-disabled-indicator[hidden] {
display: none;
}Field and Form#
Inside a Field, Select.Trigger receives the Field's id, label, description, error message, invalid, disabled, and required states. Add Select.HiddenInput to participate in native <form> submission and reset.
import { component$, useComputed$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Field } from '@leve-ui/field';
import { Select } from '@leve-ui/select';
import { LuCheck, LuChevronDown } from '@qwikest/icons/lucide';
import styles from './field.css?inline';
const COUNTRIES = [
{ value: 'jp', label: 'Japan' },
{ value: 'us', label: 'United States' },
{ value: 'uk', label: 'United Kingdom' },
];
export default component$(() => {
useStyles$(styles);
const country = useSignal<string | null>(null);
const submitted = useSignal(false);
const result = useSignal<string | null>(null);
const invalid = useComputed$(() => submitted.value && country.value === null);
const status = useComputed$(() => (result.value !== null ? `Submitted: ${result.value}` : ''));
return (
<form
class="select-field-form"
noValidate
preventdefault:submit
onSubmit$={(_event, form) => {
submitted.value = true;
if (country.value === null) return;
const data = new FormData(form);
result.value = String(data.get('country') ?? '');
}}
onReset$={() => {
submitted.value = false;
result.value = null;
}}
>
<Field.Root hasDescription invalid={invalid.value} required class="select-field">
<Field.Label class="select-field-label">Country</Field.Label>
{/* position: relative keeps HiddenInput anchored inside Root */}
<Select.Root bind:value={country} class="select-field-root">
<Select.Trigger class="select-field-trigger">
<Select.Value placeholder="Choose a country" class="select-field-value" />
<LuChevronDown aria-hidden="true" class="select-field-icon" />
</Select.Trigger>
<Select.HiddenInput name="country" />
<Select.Content sideOffset={4} class="select-field-content">
<Select.List>
{COUNTRIES.map((item) => (
<Select.Item key={item.value} value={item.value} class="select-field-item">
<Select.ItemText>{item.label}</Select.ItemText>
<Select.ItemIndicator class="select-field-indicator">
<LuCheck aria-hidden="true" class="select-field-icon" />
</Select.ItemIndicator>
</Select.Item>
))}
</Select.List>
</Select.Content>
</Select.Root>
<Field.Description class="select-field-description">
Used for shipping and tax calculation.
</Field.Description>
<Field.ErrorMessage class="select-field-error">Please select a country.</Field.ErrorMessage>
</Field.Root>
<div class="select-field-actions">
<button type="submit" class="select-field-button">
Submit
</button>
<button
type="reset"
class="select-field-button"
onClick$={() => {
country.value = null;
}}
>
Reset
</button>
</div>
<p class="select-field-status">{status.value}</p>
</form>
);
});.select-field-form {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 12px;
font-family: inherit;
}
.select-field {
display: flex;
flex-direction: column;
gap: 6px;
width: 240px;
}
.select-field-label {
font-size: 14px;
font-weight: 500;
color: light-dark(#0f172a, #ffffff);
}
.select-field-root {
/* HiddenInput is absolutely positioned inside Root */
position: relative;
}
.select-field-trigger {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
width: 100%;
padding: 8px 10px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font: inherit;
font-size: 14px;
cursor: pointer;
text-align: left;
}
.select-field-trigger:hover {
background: light-dark(#f1f5f9, #ffffff14);
}
.select-field-trigger:focus-visible {
outline: 2px solid #009dfd;
outline-offset: 2px;
}
.select-field-trigger[data-invalid] {
border-color: light-dark(#dc2626, #f87171);
}
.select-field-value[data-placeholder] {
color: light-dark(#475569, #c9ddf0);
}
.select-field-icon {
flex-shrink: 0;
width: 16px;
height: 16px;
}
/* The Content is a popover in the top layer; the library sets its position */
.select-field-content {
box-sizing: border-box;
width: var(--leve-select-anchor-width);
max-height: min(240px, var(--leve-select-available-height));
overflow-y: auto;
padding: 4px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font-family: inherit;
box-shadow: 0 8px 24px rgb(15 23 42 / 0.18);
}
.select-field-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 8px;
border-radius: 4px;
font-size: 14px;
cursor: default;
}
.select-field-item[data-highlighted] {
background: #009dfd;
color: #ffffff;
}
.select-field-indicator {
display: inline-flex;
}
.select-field-indicator[hidden] {
display: none;
}
.select-field-description {
margin: 0;
font-size: 13px;
color: light-dark(#475569, #c9ddf0);
}
.select-field-error {
margin: 0;
font-size: 13px;
color: light-dark(#dc2626, #f87171);
}
.select-field-actions {
display: flex;
gap: 8px;
}
.select-field-button {
height: 32px;
padding: 0 12px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font: inherit;
font-size: 13px;
font-weight: 500;
cursor: pointer;
}
.select-field-button:hover {
background: light-dark(#f1f5f9, #ffffff14);
}
.select-field-button:focus-visible {
outline: 2px solid #009dfd;
outline-offset: 2px;
}
.select-field-status {
margin: 0;
font-size: 13px;
color: light-dark(#475569, #c9ddf0);
}
.select-field-status:empty {
display: none;
}Controlled#
Use bind:value to read and update the selected value with a signal. Setting it to null restores the placeholder.
Current value: banana
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Select } from '@leve-ui/select';
import { LuCheck, LuChevronDown } from '@qwikest/icons/lucide';
import styles from './controlled.css?inline';
export default component$(() => {
useStyles$(styles);
const selected = useSignal<string | null>('banana');
return (
<div class="select-controlled">
<Select.Root bind:value={selected} class="select-controlled-root">
<Select.Label class="select-controlled-label">Favorite fruit</Select.Label>
<Select.Trigger class="select-controlled-trigger">
<Select.Value placeholder="Select a fruit" class="select-controlled-value" />
<LuChevronDown aria-hidden="true" class="select-controlled-icon" />
</Select.Trigger>
<Select.Content sideOffset={4} class="select-controlled-content">
<Select.List>
<Select.Item value="apple" class="select-controlled-item">
<Select.ItemText>Apple</Select.ItemText>
<Select.ItemIndicator class="select-controlled-indicator">
<LuCheck aria-hidden="true" class="select-controlled-icon" />
</Select.ItemIndicator>
</Select.Item>
<Select.Item value="banana" class="select-controlled-item">
<Select.ItemText>Banana</Select.ItemText>
<Select.ItemIndicator class="select-controlled-indicator">
<LuCheck aria-hidden="true" class="select-controlled-icon" />
</Select.ItemIndicator>
</Select.Item>
<Select.Item value="orange" class="select-controlled-item">
<Select.ItemText>Orange</Select.ItemText>
<Select.ItemIndicator class="select-controlled-indicator">
<LuCheck aria-hidden="true" class="select-controlled-icon" />
</Select.ItemIndicator>
</Select.Item>
</Select.List>
</Select.Content>
</Select.Root>
<div class="select-controlled-controls">
<button
type="button"
class="select-controlled-button"
onClick$={() => {
selected.value = 'apple';
}}
>
Select Apple
</button>
<button
type="button"
class="select-controlled-button"
onClick$={() => {
selected.value = 'orange';
}}
>
Select Orange
</button>
<button
type="button"
class="select-controlled-button"
onClick$={() => {
selected.value = null;
}}
>
Clear Selection
</button>
</div>
<p class="select-controlled-status">Current value: {selected.value ?? 'none'}</p>
</div>
);
});.select-controlled {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 12px;
font-family: inherit;
}
.select-controlled-root {
display: flex;
flex-direction: column;
gap: 6px;
width: 240px;
}
.select-controlled-label {
font-size: 14px;
font-weight: 500;
color: light-dark(#0f172a, #ffffff);
}
.select-controlled-trigger {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
width: 100%;
padding: 8px 10px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font: inherit;
font-size: 14px;
cursor: pointer;
text-align: left;
}
.select-controlled-trigger:hover {
background: light-dark(#f1f5f9, #ffffff14);
}
.select-controlled-trigger:focus-visible {
outline: 2px solid #009dfd;
outline-offset: 2px;
}
.select-controlled-value[data-placeholder] {
color: light-dark(#475569, #c9ddf0);
}
.select-controlled-icon {
flex-shrink: 0;
width: 16px;
height: 16px;
}
/* The Content is a popover in the top layer; the library sets its position */
.select-controlled-content {
box-sizing: border-box;
width: var(--leve-select-anchor-width);
max-height: min(240px, var(--leve-select-available-height));
overflow-y: auto;
padding: 4px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font-family: inherit;
box-shadow: 0 8px 24px rgb(15 23 42 / 0.18);
}
.select-controlled-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 8px;
border-radius: 4px;
font-size: 14px;
cursor: default;
}
.select-controlled-item[data-highlighted] {
background: #009dfd;
color: #ffffff;
}
.select-controlled-indicator {
display: inline-flex;
}
.select-controlled-indicator[hidden] {
display: none;
}
.select-controlled-controls {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.select-controlled-button {
height: 32px;
padding: 0 12px;
border: 1px solid light-dark(#cbd5e1, #ffffff3d);
border-radius: 6px;
background: light-dark(#ffffff, #1b2045);
color: light-dark(#0f172a, #ffffff);
font: inherit;
font-size: 13px;
font-weight: 500;
cursor: pointer;
}
.select-controlled-button:hover {
background: light-dark(#f1f5f9, #ffffff14);
}
.select-controlled-button:focus-visible {
outline: 2px solid #009dfd;
outline-offset: 2px;
}
.select-controlled-status {
margin: 0;
font-size: 13px;
color: light-dark(#475569, #c9ddf0);
}API Reference#
Root#
| Prop | Default | Type |
|---|---|---|
| ids | – | { label?: string; trigger?: string; list?: string } Overrides the element IDs of the parts. Inside a Field, the Field's IDs are used for the label and trigger. |
| defaultValue | null | string | null The value of the selected item initially (uncontrolled). |
| bind:value | – | Signal<string | null> A signal with the value of the selected item (controlled). |
| onValueChange$ | – | QRL<(value: string | null) => void> Called when the selected value changes. |
| defaultOpen | false | boolean Whether the listbox is open initially (uncontrolled). |
| bind:open | – | Signal<boolean> A signal with the open state of the listbox (controlled). |
| onOpenChange$ | – | QRL<(open: boolean) => void> Called when the listbox opens or closes. |
| disabled | false | boolean Whether the select is disabled. Inside a Field or Fieldset, inherited |
| required | false | boolean Whether a value is required in a form. Inside a Field, the Field's |
| loop | false | boolean Whether ArrowDown on the last item moves to the first one, and ArrowUp on the first to the last. |
Also accepts all <div> attributes.
| Data attribute | Value |
|---|---|
data-leve-select | Always present |
data-state | "open" | "closed" |
data-disabled | Present when disabled |
Label#
No props of its own. Accepts all <label> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-label | Always present |
data-disabled | Present when disabled |
Trigger#
| Prop | Default | Type |
|---|---|---|
| invalid | false | boolean Whether the select value is invalid. Inside a Field, the Field's |
Also accepts all <button> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-trigger | Always present |
data-state | "open" | "closed" |
data-placeholder | Present when no option is selected |
data-disabled | Present when disabled |
data-invalid | Present when invalid |
Value#
| Prop | Default | Type |
|---|---|---|
| placeholder | – | string Text displayed when no item is selected. |
Also accepts all <span> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-value | Always present |
data-placeholder | Present when no option is selected |
When defaultValue or bind:value has an initial value, Select.Value resolves the matching option's text from the DOM on the client. Pass fallback text as children (for example, <Select.Value>Banana</Select.Value>) so the initial label renders during SSR before the client resolves it.
HiddenInput#
| Prop | Default | Type |
|---|---|---|
| form | – | string The |
Also accepts all <input> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-hidden-input | Always present |
It is positioned absolutely, so give Select.Root position: relative.
Content#
| Prop | Default | Type |
|---|---|---|
| side | 'bottom' | 'top' | 'right' | 'bottom' | 'left' The side of the Trigger to place the listbox on. It flips when there is no room. |
| align | 'start' | 'start' | 'center' | 'end' The alignment along that side. |
| sideOffset | 0 | number The distance from the Trigger in px. |
| alignOffset | 0 | number The offset along the side in px. |
| avoidCollisions | true | boolean Whether to flip and shift the listbox to keep it in the viewport. |
| collisionPadding | 0 | number The padding from the viewport edges when avoiding collisions, in px. |
Also accepts all <div> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-content | Always present |
data-state | "open" | "closed" |
data-side | The final side after flipping |
data-align | "start" | "center" | "end" |
| CSS variable | Value |
|---|---|
--leve-select-anchor-width | The width of the Trigger, for example to match the listbox width |
--leve-select-anchor-height | The height of the Trigger |
--leve-select-available-width | The width available in the viewport |
--leve-select-available-height | The height available in the viewport, for example for max-height |
List#
No props of its own. Accepts all <div> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-list | Always present |
Item#
| Prop | Default | Type |
|---|---|---|
| value (required) | – | string The value of the item. Must be unique within the select. |
| disabled | false | boolean Whether the item cannot be selected. Arrow keys and typeahead skip it. |
| textValue | – | string The display and typeahead text for the item, when it differs from |
Also accepts all <div> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-item | Always present |
data-value | The value |
data-state | "checked" | "unchecked" |
data-highlighted | Present on the highlighted option |
data-disabled | Present when disabled |
data-text-value | The textValue, when set |
Focus stays on the trigger, so style the highlighted option with [data-highlighted], not :focus.
ItemText#
No props of its own. Accepts all <span> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-item-text | Always present |
ItemIndicator#
No props of its own. Accepts all <span> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-item-indicator | Always present |
data-state | "checked" | "unchecked" |
It has the hidden attribute while the option is unselected. If you set display on it, hide it again with [hidden] { display: none; }.
Group#
No props of its own. Accepts all <div> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-group | Always present |
GroupLabel#
No props of its own. Accepts all <div> attributes.
| Data attribute | Value |
|---|---|
data-leve-select-group-label | Always present |
Accessibility#
Complies with the Select-Only Combobox WAI-ARIA design pattern.
Select.Triggerrenders<button type="button" role="combobox">witharia-haspopup="listbox",aria-expanded,aria-controls, andaria-labelledby. Focus stays on the trigger, andaria-activedescendantpoints to the highlighted option while open.Select.Listrendersrole="listbox", named by the label. Options renderrole="option"witharia-selected; disabled options renderaria-disabled="true"and are skipped by arrow keys and typeahead.Select.Grouprendersrole="group", named by itsSelect.GroupLabel.Select.ItemIndicatoris hidden from assistive technologies witharia-hidden="true", sincearia-selectedconveys the state.- Inside a Field, the trigger receives the Field's id, label, description, error message,
invalid,disabled, andrequiredstates.
Keyboard Interactions#
| Key | Description |
|---|---|
Enter / Space | When closed, opens the listbox and highlights the selected option (or the first enabled option). When open, selects the highlighted option and closes. |
ArrowDown | When closed, opens the listbox and highlights the selected option (or the first enabled option). When open, highlights the next enabled option. |
ArrowUp | When closed, opens the listbox and highlights the selected option (or the last enabled option). When open, highlights the previous enabled option (or closes with Alt + ArrowUp). |
Home | Opens the listbox if closed and highlights the first enabled option. |
End | Opens the listbox if closed and highlights the last enabled option. |
Escape | Closes the listbox without changing the value and keeps focus on the trigger. |
Tab | Closes the listbox and moves focus to the next focusable element. |
| Characters | Typeahead: jumps to the matching enabled option (and opens the listbox if closed). |