Select
Pick one or more options from a list that opens on the current value, with typeahead, groups and form support.
- Form components
- 10 parts
- 9 examples
@base-ui/react@tabler/icons-reactclass-variance-authority
See it in a real product: Image Studio, Memory, Prompt Library, and 13 more
View blockpnpm dlx shadcn@latest add https://hextaui.com/r/select.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add @base-ui/react @tabler/icons-react class-variance-authority cnCopy and paste the following code into your project.
components/ui/select.tsx lib/motion.ts Update the import paths to match your project setup.
The list opens right over the trigger with the current option lined up on top of the value, so your eye never loses its place. Pass items so SelectValue shows labels instead of raw values. For long lists that need searching, use Combobox.
size on SelectTrigger matches Input and Button heights.
Group options with SelectGroup and SelectLabel. Long lists fit the screen and show scroll arrows that scroll when you hover them.
Put icons in items, and pass a function to SelectValue to show the same icon in the trigger.
With multiple, the list stays open while you pick, and the value can summarise long selections.
Inside Field, the trigger gets its label, description and required validation.
Disable the whole select or single options, and mark it invalid with aria-invalid.
alignItemWithTrigger={false} opens the list under the trigger like a menu. Touch input does this automatically.
The trigger, list and check follow the reading direction.
| Key | Action |
|---|---|
| SpaceEnter↓↑ | Opens the list from the trigger. |
| ↓↑ | Moves between options. |
| HomeEnd | Moves to the first or last option. |
| A–Z | Jumps to the next option that starts with the typed text. |
| EnterSpace | Picks the highlighted option. |
| Esc | Closes the list and returns focus to the trigger. |
- Label the trigger with
FieldLabeloraria-label. - On touch, the list opens below the trigger instead of over it, so your finger doesn't land on an option.
| Prop | Type | Default |
|---|---|---|
value | Value | Value[] | null | – |
defaultValue | Value | Value[] | null | – |
onValueChange | (value, details) => void | – |
itemsLets SelectValue show labels. | Record<string, ReactNode> | { value, label }[] | – |
multiple | boolean | false |
name | string | – |
required | boolean | false |
disabled | boolean | false |
readOnly | boolean | false |
open | boolean | – |
onOpenChange | (open, details) => void | – |
| Prop | Type | Default |
|---|---|---|
size | "sm" | "default" | "lg" | "default" |
render | ReactElement | (props, state) => ReactElement | <button> |
| Attribute | Description |
|---|---|
data-slot="select-trigger" | The trigger, with data-size. |
data-popup-open | Present while the list is open. |
data-placeholder | Present while nothing is picked. |
| Prop | Type | Default |
|---|---|---|
placeholder | ReactNode | – |
childrenFormat the shown value. | ReactNode | (value) => ReactNode | – |
| Prop | Type | Default |
|---|---|---|
alignItemWithTriggerOpen over the trigger with the current option lined up. | boolean | true |
sideWhen not aligned with the trigger. | "top" | "bottom" | … | "bottom" |
align | "start" | "center" | "end" | "start" |
sideOffset | number | 6 |
| Attribute | Description |
|---|---|
data-slot="select-content" | The popup. |
data-side="none" | Present while aligned over the trigger. |
| Prop | Type | Default |
|---|---|---|
value | Value | – |
disabled | boolean | false |
labelText for typeahead. | string | – |
| Attribute | Description |
|---|---|
data-selected | The picked option. |
data-highlighted | The focused option. |
data-disabled | The option is disabled. |
- CalendarA date grid for single, range and multiple selection, with sliding months, range previews and touch-sized days.
- CheckboxA checkbox whose check draws in, with indeterminate parents, groups and labels that share its hover.
- ComboboxA filterable select with chips, groups and async results, in a popup that resizes as you type.
- Date pickerA button that opens a calendar in a popover, or a bottom sheet on phones, for single dates and ranges.
- FieldLabels, descriptions and errors wired to their control, with validation states and layouts for forms.
- InputA text input with three sizes, invalid and read-only states, native validation styling and a 16px touch font so phones never zoom in.
Used in Pro blocks
Blocks that build on Select.
Every block comes with HextaUI Pro, and Prompt Input is free.