A dropdown select component with keyboard navigation, typeahead, and optional item-to-trigger alignment. Replaces native <select> with a fully styled, accessible alternative.
- Picking a single value from a predefined list of options.
- When you need typeahead, keyboard navigation, and full styling control.
- Prefer Select over Autocomplete when the user should choose from a fixed list without typing to filter.
import { Select } from '@/primitives/select';
<Select.Root>
<Select.Trigger>
<Select.Value placeholder='Choose a fruit...' />
</Select.Trigger>
<Select.Positioner>
<Select.Popup>
<Select.Option
value='apple'
label='Apple'
/>
<Select.Option
value='banana'
label='Banana'
/>
<Select.Option
value='cherry'
label='Cherry'
/>
</Select.Popup>
</Select.Positioner>
</Select.Root>;const [value, setValue] = useState('apple');
<Select.Root
value={value}
onValueChange={setValue}
>
{/* ... */}
</Select.Root>;The items prop allows label resolution before options mount (useful for server rendering or deferred lists):
const items = [
{ value: 'apple', label: 'Apple' },
{ value: 'banana', label: 'Banana' },
];
<Select.Root
items={items}
defaultValue='apple'
>
{/* Select.Value will display "Apple" even before Options mount */}
</Select.Root>;By default, the selected option visually aligns with the trigger. Disable this for standard dropdown positioning:
<Select.Root alignItemWithTrigger={false}>{/* Uses standard Floating UI positioning */}</Select.Root>| Part | Default Element | Description |
|---|---|---|
Select.Root |
— | Root context provider |
Select.Trigger |
<button> |
Toggles the dropdown on click |
Select.Value |
<span> |
Displays the selected label or placeholder |
Select.Portal |
— | Portals children (accepts root prop) |
Select.Positioner |
<div> |
Floating positioned container |
Select.Popup |
<div> |
Visual wrapper for the option list |
Select.Option |
<button> |
A selectable option |
Select.Arrow |
<svg> |
Optional floating arrow |
| Prop | Type | Default | Description |
|---|---|---|---|
value |
string |
— | Controlled selected value |
defaultValue |
string |
— | Initial selected value (uncontrolled) |
onValueChange |
(value: string) => void |
— | Called when selection changes |
open |
boolean |
— | Controlled open state |
defaultOpen |
boolean |
false |
Initial open state (uncontrolled) |
onOpenChange |
(open: boolean) => void |
— | Called when open state changes |
items |
SelectItem[] |
— | { label, value } pairs for label resolution before options mount |
alignItemWithTrigger |
boolean |
true |
Visually align selected option over the trigger |
placement |
Placement |
"bottom-start" |
Floating UI placement |
sideOffset |
number |
4 |
Gap between trigger and popup (px) |
| Prop | Type | Default | Description |
|---|---|---|---|
placeholder |
ReactNode |
— | Shown when no value is selected |
| Prop | Type | Default | Description |
|---|---|---|---|
value |
string |
required | The option's value |
label |
string |
falls back to value |
Display label, also used for typeahead |
disabled |
boolean |
— | Prevents selection |
No additional props beyond standard HTML attributes and the render prop.
Accepts all FloatingArrow props. ref and context are injected automatically.
| Key | Action |
|---|---|
ArrowDown |
Move to next option |
ArrowUp |
Move to previous option |
Enter / Space |
Select the active option, close popup |
Escape |
Close the popup |
| Type a character | Jump to matching option (typeahead) |
Typeahead is active only while the popup is open. It highlights the matching option; pressing Enter or Space then selects it.
| Attribute | Applies To | Description |
|---|---|---|
data-open / data-closed |
Trigger | Popup open state |
data-selected |
Option | The currently selected option |
data-active |
Option | The keyboard-highlighted option |
data-disabled |
Option | Disabled option |
data-side |
Positioner | Resolved placement side |
labelonSelect.Optiondrives both display inSelect.Valueand typeahead matching. If omitted,valueis used for both.itemsprop is only for label resolution — it does not control which options render. You still renderSelect.Optionchildren yourself.- Disabled options can still receive keyboard focus but cannot be selected.
- Popup:
role="listbox" - Option:
role="option",aria-selected,aria-disabled - Trigger:
aria-expanded,aria-haspopup="listbox",aria-controls