Native select
The browser's own select, styled to match Input, with a quiet placeholder, Field support and the OS picker on every device.
- Form components
- 3 parts
- 9 examples
@base-ui/react@tabler/icons-react
See it in a real product: Address Form
View blockpnpm dlx shadcn@latest add https://hextaui.com/r/native-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/native-select.tsx components/ui/input.tsx components/ui/number-flow.tsx lib/motion.ts Update the import paths to match your project setup.
An option with an empty value acts as the placeholder: it shows in muted text until something is chosen. Put className on the select to size its wrapper, for example w-full.
<NativeSelectOptGroup /> organizes options under headings in the OS picker.
Sizes, borders, focus rings and invalid styles match Input exactly, so the two line up in a row.
Inside a <Field />, the label and description connect on their own and errors show as the value changes. Submit without a plan and the select turns red, shakes once, and the browser points to it.
Set aria-invalid and link the message with aria-describedby.
Disable the whole select, or single options that aren't available.
Pass value and onChange like a regular select.
Long selected labels end with an ellipsis instead of running under the chevron.
The chevron and padding move to the other side.
- Use Native select for simple lists, especially on phones, where the OS picker is the fastest and most familiar way to choose.
- Use Combobox when people need to search, or when options need icons, descriptions or custom layouts.
| Key | Action |
|---|---|
| Tab | Focuses the select. |
| SpaceEnter | Opens the OS picker. |
| ↑↓ | Changes the selection, or moves in the open picker. |
| A–Z | Jumps to the option that starts with the typed text. |
<NativeSelect /> accepts every select attribute. The option parts accept their element's attributes.
| Prop | Type | Default |
|---|---|---|
size | "sm" | "default" | "lg" | "default" |
htmlSizeThe native size attribute, renamed because size is the variant. | number | – |
shakeShake once when a form submit finds it invalid. | boolean | true |
classNameApplied to the wrapper, so it sizes the whole control. | string | – |
value | string | – |
defaultValue | string | – |
disabled | boolean | false |
required | boolean | false |
| Attribute | Description |
|---|---|
data-slot="native-select-wrapper" | The wrapper, with data-size. |
data-slot="native-select" | The select element. |
data-slot="native-select-icon" | The chevron. Darkens on hover and focus. |
data-invalid | Present when a surrounding Field is invalid. |
| Attribute | Description |
|---|---|
data-slot="native-select-option" | An option. |
data-slot="native-select-optgroup" | A labelled group of options. |
- InputA text input with three sizes, invalid and read-only states, native validation styling and a 16px touch font so phones never zoom in.
- useComposedRefKeeps a ref to your own element while still forwarding it to whatever ref the parent passed in.
- useInvalidShakeShakes a form control when a submit attempt finds it invalid, and never while someone is still typing.
- 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.
Used in Pro blocks
Blocks that build on Native select.
Every block comes with HextaUI Pro, and Prompt Input is free.