# Native Select

> Choose one option with the browser's own select, styled to match Honest UI fields.

Source: https://www.honestui.com/docs/components/native-select

```tsx
import {
  NativeSelect,
  NativeSelectOption,
} from "@/components/honest-ui/ui/native-select"

export function NativeSelectDemo() {
  return (
    <NativeSelect
      aria-label="Status"
      defaultValue="in-progress"
      wrapperClassName="max-w-64"
    >
      <NativeSelectOption value="backlog">Backlog</NativeSelectOption>
      <NativeSelectOption value="todo">To do</NativeSelectOption>
      <NativeSelectOption value="in-progress">In progress</NativeSelectOption>
      <NativeSelectOption value="in-review">In review</NativeSelectOption>
      <NativeSelectOption value="done">Done</NativeSelectOption>
    </NativeSelect>
  )
}

```

## Overview [#overview]

Native Select is a real `<select>` element dressed in the same edge, fill, focus ring, and sizes as the [Select](/docs/components/select) trigger. The closed control looks like the rest of your form. In browsers that support customizable selects (`appearance: base-select`, currently Chromium-based browsers), the open list is drawn like the Select popup: the same overlay surface, padded rows, hover tint, and a trailing check on the chosen option. Elsewhere it falls back to the platform's own picker: a wheel on iOS, a system list in Safari and Firefox. Either way it stays a real `<select>`, so the form value, keyboard behavior, and autofill are the browser's.

## Native Select vs Select [#native-select-vs-select]

Both choose one value from a list. They differ in what opens.

Choose **Native Select** when:

* Most people use the form on a phone. The platform picker is large, familiar, and scrolls with momentum.
* The form must work before JavaScript loads, or posts as a plain HTML form.
* The list is long and plain, such as countries or time zones, and typing the first letters to jump is enough.
* The control sits in a dense table or toolbar where a custom popup would be heavy.

Choose **Select** when options need icons, descriptions, avatars, or custom rendering; when you need multiple selection with chips; or when the open list must look the same in every browser. Choose [Combobox](/docs/components/combobox) when people need to search a long list.

## Anatomy [#anatomy]

The component renders a wrapper span, the `<select>` itself, and a chevron drawn over the end of the control. The browser's arrow is removed with `appearance: none`, and the end padding leaves room for the chevron, which ignores pointer events so clicks always reach the select. Children are ordinary `<option>` and `<optgroup>` elements, exported as `NativeSelectOption` and `NativeSelectOptGroup`.

## Accessibility [#accessibility]

A native select carries the strongest accessibility support on the web: the `combobox` or `listbox` role, keyboard handling, type-ahead, and screen reader announcements all come from the browser. Give it a name with a visible label. Inside a [Field](/docs/components/field), `FieldLabel` labels it automatically, `FieldDescription` describes it, and validation sets `data-invalid` so the edge turns red alongside a written `FieldError`. Outside a Field, use a `<label htmlFor>` or `aria-label`.

The chevron is `aria-hidden`. Invalid, disabled, and focus states match Input and Select, and the control keeps a system border in forced-colors mode. Option rows use the overlay surface so platforms that paint the open list with page colors stay legible in dark mode.

## Installation [#installation]


  

  
    <CliBlock commands="[&#x22;native-select&#x22;]" />
  

  
    
      
        Install the following dependencies:
      

      ```bash
      npm install @base-ui/react class-variance-authority
      ```

      
        Copy and paste the following code into your project.
      

      ### components/ui/native-select.tsx

```tsx
"use client"

import * as React from "react"
import { Field as FieldPrimitive } from "@base-ui/react/field"
import { cva, type VariantProps } from "class-variance-authority"
import { ChevronDown as ChevronDownIcon } from "honestui/icons"

import { cn } from "@/lib/utils"

// The same edge, fill, focus ring, and states as the Select trigger, applied
// to a real <select>. The browser's arrow is removed and the end padding
// leaves room for the chevron drawn over the control.
const nativeSelectVariants = cva(
  [
    "box-border w-full min-w-0 cursor-pointer appearance-none truncate rounded-[var(--hui-radius-2)] bg-[var(--hui-color-background-field,var(--hui-color-background-base-primary))] text-[var(--hui-color-foreground-base-primary)] outline-none [font-size:var(--hui-font-size-control,13px)] [font-weight:var(--hui-font-weight-regular)] [letter-spacing:var(--hui-letter-spacing-control,-0.003em)] [line-height:var(--hui-line-height-control,16px)] motion-safe:[transition:var(--hui-transition-interactive)]",
    // Focus: the field ring, the same as Input and the Select trigger.
    "focus:border-[var(--hui-color-border-accent-emphasis)] focus:outline-2 focus:outline-solid focus:outline-transparent focus:shadow-[var(--hui-focus-ring-field)] focus:outline-offset-[var(--hui-focus-ring-offset-inset-border)]",
    // Invalid: from Field validation (data-invalid) or a hand-set aria-invalid.
    "data-invalid:border-[var(--hui-color-border-danger-emphasis)] aria-invalid:border-[var(--hui-color-border-danger-emphasis)] data-invalid:focus:border-[var(--hui-color-border-danger-emphasis-hover)] aria-invalid:focus:border-[var(--hui-color-border-danger-emphasis-hover)] data-invalid:focus:shadow-[var(--hui-focus-ring-field-danger)] aria-invalid:focus:shadow-[var(--hui-focus-ring-field-danger)]",
    "disabled:cursor-not-allowed disabled:bg-[var(--hui-color-background-base-secondary)] disabled:text-[var(--hui-color-foreground-base-tertiary)] data-disabled:cursor-not-allowed data-disabled:bg-[var(--hui-color-background-base-secondary)] data-disabled:text-[var(--hui-color-foreground-base-tertiary)]",
    // Some platforms paint the open list with page colors, so options take
    // the overlay surface to stay legible in dark mode.
    "[&_option]:bg-[var(--hui-color-background-overlay)] [&_option]:text-[var(--hui-color-foreground-base-primary)] [&_optgroup]:bg-[var(--hui-color-background-overlay)] [&_optgroup]:text-[var(--hui-color-foreground-base-secondary)]",
    // Customizable select: where the browser supports appearance: base-select,
    // the element stays a real <select> (form value, keyboard, autofill) but
    // its open list is drawn like the Select popup: the overlay surface,
    // padded rows with the overlay hover, and a trailing check on the chosen
    // row only. Other browsers keep the platform picker above.
    "supports-[appearance:base-select]:[appearance:base-select] supports-[appearance:base-select]:flex supports-[appearance:base-select]:items-center supports-[appearance:base-select]:py-0 supports-[appearance:base-select]:[&::picker-icon]:hidden",
    "supports-[appearance:base-select]:[&::picker(select)]:[appearance:base-select] supports-[appearance:base-select]:[&::picker(select)]:box-border supports-[appearance:base-select]:[&::picker(select)]:my-[var(--hui-space-2)] supports-[appearance:base-select]:[&::picker(select)]:rounded-[var(--hui-radius-2)] supports-[appearance:base-select]:[&::picker(select)]:[border:0.5px_solid_var(--hui-color-border-overlay)] supports-[appearance:base-select]:[&::picker(select)]:bg-[var(--hui-color-background-overlay)] supports-[appearance:base-select]:[&::picker(select)]:p-[var(--hui-space-2)] supports-[appearance:base-select]:[&::picker(select)]:text-[var(--hui-color-foreground-base-primary)] supports-[appearance:base-select]:[&::picker(select)]:shadow-[var(--hui-shadow-overlay,var(--hui-shadow-soft))]",
    "supports-[appearance:base-select]:[&_option]:flex supports-[appearance:base-select]:[&_option]:cursor-pointer supports-[appearance:base-select]:[&_option]:items-center supports-[appearance:base-select]:[&_option]:gap-[var(--hui-space-3)] supports-[appearance:base-select]:[&_option]:min-h-[var(--hui-density-item-min-height,0px)] supports-[appearance:base-select]:[&_option]:rounded-[var(--hui-radius-item,var(--hui-radius-2))] supports-[appearance:base-select]:[&_option]:px-[var(--hui-space-3)] supports-[appearance:base-select]:[&_option]:py-[var(--hui-density-item-padding-block,var(--hui-space-3))] supports-[appearance:base-select]:[&_option]:bg-transparent supports-[appearance:base-select]:[&_option]:outline-none supports-[appearance:base-select]:[&_option]:[font-size:var(--hui-font-size-control,13px)] supports-[appearance:base-select]:[&_option]:[font-weight:var(--hui-font-weight-regular)] supports-[appearance:base-select]:[&_option:is(:hover,:focus-visible)]:bg-[var(--hui-color-background-overlay-hover)] supports-[appearance:base-select]:[&_option:disabled]:cursor-not-allowed supports-[appearance:base-select]:[&_option:disabled]:bg-transparent supports-[appearance:base-select]:[&_option:disabled]:text-[var(--hui-color-foreground-base-tertiary)]",
    // The check is the Check icon as a mask, shown only on the chosen row so
    // other rows don't reserve empty space for it.
    "supports-[appearance:base-select]:[&_option::checkmark]:order-1 supports-[appearance:base-select]:[&_option::checkmark]:ms-auto supports-[appearance:base-select]:[&_option::checkmark]:size-4 supports-[appearance:base-select]:[&_option::checkmark]:shrink-0 supports-[appearance:base-select]:[&_option::checkmark]:bg-current supports-[appearance:base-select]:[&_option::checkmark]:content-[''] supports-[appearance:base-select]:[&_option::checkmark]:[mask:url(data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2024%2024%22%20fill=%22none%22%20stroke=%22black%22%20stroke-width=%221.5%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%3Cpath%20d=%22M20%206%209%2017l-5-5%22/%3E%3C/svg%3E)_center/contain_no-repeat] supports-[appearance:base-select]:[&_option:not(:checked)::checkmark]:hidden",
    // Group labels match SelectLabel; their options reset to row styling.
    "supports-[appearance:base-select]:[&_optgroup]:bg-transparent supports-[appearance:base-select]:[&_optgroup]:[font-size:var(--hui-font-size-small)] supports-[appearance:base-select]:[&_optgroup]:[font-weight:var(--hui-font-weight-medium)] supports-[appearance:base-select]:[&_optgroup]:text-[var(--hui-color-foreground-base-secondary)] supports-[appearance:base-select]:[&_optgroup_option]:text-[var(--hui-color-foreground-base-primary)]",
    // Forced colors drop custom fills, so keep a system border.
    "forced-colors:border forced-colors:border-[ButtonText]",
  ],
  {
    variants: {
      size: {
        sm: "h-[var(--hui-control-height-sm,var(--hui-space-8))] ps-[var(--hui-field-padding-inline,var(--hui-space-3))] pe-[calc(var(--hui-field-padding-inline,var(--hui-space-3))+var(--hui-space-4)+var(--hui-space-2))] [font-size:var(--hui-font-size-control-sm,var(--hui-font-size-small))]",
        default:
          "h-[var(--hui-density-control-height,36px)] ps-[var(--hui-field-padding-inline,var(--hui-space-3))] pe-[calc(var(--hui-field-padding-inline,var(--hui-space-3))+var(--hui-space-5)+var(--hui-space-3))]",
        lg: "h-[var(--hui-control-height-lg,44px)] ps-[var(--hui-space-4)] pe-[calc(var(--hui-space-4)+var(--hui-space-5)+var(--hui-space-3))]",
      },
      variant: {
        outline:
          "border-[0.5px] border-[var(--hui-color-border-field,var(--hui-color-border-base-tertiary))] not-focus:not-disabled:not-data-disabled:not-data-invalid:not-aria-invalid:hover:border-[var(--hui-color-border-field-hover,var(--hui-color-border-field,var(--hui-color-border-base-tertiary)))] disabled:border-[var(--hui-color-border-base-primary)] data-disabled:border-[var(--hui-color-border-base-primary)]",
        text: "border-0 not-disabled:not-data-disabled:hover:bg-[var(--hui-color-background-base-primary-hover)] not-disabled:not-data-disabled:active:bg-[var(--hui-color-background-neutral-secondary)]",
      },
    },
    defaultVariants: {
      size: "default",
      variant: "outline",
    },
  }
)

type NativeSelectProps = Omit<React.ComponentProps<"select">, "size"> &
  VariantProps<typeof nativeSelectVariants> & {
    /** Classes for the wrapper that positions the chevron. */
    wrapperClassName?: string
  }

function NativeSelect({
  className,
  wrapperClassName,
  size = "default",
  variant = "outline",
  children,
  ...props
}: NativeSelectProps) {
  return (
    <span
      data-slot="native-select-wrapper"
      data-size={size}
      className={cn("relative inline-flex w-full", wrapperClassName)}
    >
      {/* Field.Control registers the select with a surrounding Field, so
          FieldLabel, FieldDescription, and validation work as with Input. */}
      <FieldPrimitive.Control
        data-hui=""
        data-slot="native-select"
        data-size={size}
        data-variant={variant}
        render={<select />}
        className={cn(nativeSelectVariants({ size, variant }), className)}
        {...(props as unknown as FieldPrimitive.Control.Props)}
      >
        {children}
      </FieldPrimitive.Control>
      <ChevronDownIcon
        aria-hidden="true"
        data-slot="native-select-icon"
        className={cn(
          "pointer-events-none absolute top-1/2 -translate-y-1/2 text-[var(--hui-color-foreground-base-secondary)]",
          size === "sm"
            ? "end-[var(--hui-field-padding-inline,var(--hui-space-3))] size-[var(--hui-space-4)]"
            : size === "lg"
              ? "end-[var(--hui-space-4)] size-[var(--hui-space-5)]"
              : "end-[var(--hui-field-padding-inline,var(--hui-space-3))] size-[var(--hui-space-5)]"
        )}
      />
    </span>
  )
}

function NativeSelectOption(props: React.ComponentProps<"option">) {
  return <option data-slot="native-select-option" {...props} />
}

function NativeSelectOptGroup(props: React.ComponentProps<"optgroup">) {
  return <optgroup data-slot="native-select-optgroup" {...props} />
}

export {
  NativeSelect,
  NativeSelectOption,
  NativeSelectOptGroup,
  nativeSelectVariants,
}

```

      
        Update the import paths to match your project setup.
      
    
  


## Usage [#usage]

```tsx
import {
  NativeSelect,
  NativeSelectOptGroup,
  NativeSelectOption,
} from "@/components/ui/native-select"
```

```tsx
<NativeSelect aria-label="Status" defaultValue="todo">
  <NativeSelectOption value="todo">To do</NativeSelectOption>
  <NativeSelectOption value="done">Done</NativeSelectOption>
</NativeSelect>
```

Read the value from `onChange`, as with any select: `onChange={(event) => setStatus(event.target.value)}`.

## Don't do this [#dont-do-this]

### A placeholder that can be submitted [#a-placeholder-that-can-be-submitted]

```tsx
// Bad
<NativeSelect>
  <NativeSelectOption value="">Select a country</NativeSelectOption>
  ...
</NativeSelect>
```

```tsx
// Good
<NativeSelect required defaultValue="">
  <NativeSelectOption value="" disabled>
    Select a country
  </NativeSelectOption>
  ...
</NativeSelect>
```

An empty, enabled first option is a real answer that slips through validation. Disable it and mark the select `required`.

### Rich content in options [#rich-content-in-options]

`<option>` renders plain text only. Icons, badges, and secondary lines are dropped or rendered inconsistently across browsers. Use [Select](/docs/components/select) when an option needs more than a label.

## Examples [#examples]

### Grouped options [#grouped-options]

`NativeSelectOptGroup` adds non-selectable headings. In the customizable list they take the Select group label style; the platform picker renders them natively.

```tsx
import {
  NativeSelect,
  NativeSelectOptGroup,
  NativeSelectOption,
} from "@/components/honest-ui/ui/native-select"

const zones = [
  {
    region: "Americas",
    options: [
      { value: "America/Los_Angeles", label: "Pacific Time (Los Angeles)" },
      { value: "America/Denver", label: "Mountain Time (Denver)" },
      { value: "America/Chicago", label: "Central Time (Chicago)" },
      { value: "America/New_York", label: "Eastern Time (New York)" },
      { value: "America/Sao_Paulo", label: "Brasília Time (São Paulo)" },
    ],
  },
  {
    region: "Europe",
    options: [
      { value: "Europe/London", label: "Greenwich Mean Time (London)" },
      { value: "Europe/Berlin", label: "Central European Time (Berlin)" },
      { value: "Europe/Helsinki", label: "Eastern European Time (Helsinki)" },
    ],
  },
  {
    region: "Asia and Pacific",
    options: [
      { value: "Asia/Kolkata", label: "India Standard Time (Kolkata)" },
      { value: "Asia/Singapore", label: "Singapore Time" },
      { value: "Asia/Tokyo", label: "Japan Standard Time (Tokyo)" },
      { value: "Australia/Sydney", label: "Australian Eastern Time (Sydney)" },
    ],
  },
]

export function NativeSelectGroups() {
  return (
    <NativeSelect
      aria-label="Time zone"
      defaultValue="America/New_York"
      wrapperClassName="max-w-80"
    >
      {zones.map((zone) => (
        <NativeSelectOptGroup key={zone.region} label={zone.region}>
          {zone.options.map((option) => (
            <NativeSelectOption key={option.value} value={option.value}>
              {option.label}
            </NativeSelectOption>
          ))}
        </NativeSelectOptGroup>
      ))}
    </NativeSelect>
  )
}

```

### In a form field [#in-a-form-field]

Required validation, a description, and an error message through Field.

```tsx
"use client"

import { Button } from "@/components/honest-ui/ui/button"
import {
  Field,
  FieldDescription,
  FieldError,
  FieldLabel,
} from "@/components/honest-ui/ui/field"
import { Form } from "@/components/honest-ui/ui/form"
import {
  NativeSelect,
  NativeSelectOption,
} from "@/components/honest-ui/ui/native-select"

export function NativeSelectField() {
  return (
    <Form
      className="flex w-full max-w-64 flex-col gap-[var(--hui-space-4)]"
      onSubmit={(event) => event.preventDefault()}
    >
      <Field name="country">
        <FieldLabel>Country</FieldLabel>
        <NativeSelect required defaultValue="">
          <NativeSelectOption value="" disabled>
            Select a country
          </NativeSelectOption>
          <NativeSelectOption value="au">Australia</NativeSelectOption>
          <NativeSelectOption value="ca">Canada</NativeSelectOption>
          <NativeSelectOption value="de">Germany</NativeSelectOption>
          <NativeSelectOption value="jp">Japan</NativeSelectOption>
          <NativeSelectOption value="gb">United Kingdom</NativeSelectOption>
          <NativeSelectOption value="us">United States</NativeSelectOption>
        </NativeSelect>
        <FieldDescription>Used to calculate shipping and tax.</FieldDescription>
        <FieldError>Choose the country you ship to.</FieldError>
      </Field>
      <Button type="submit" className="self-start">
        Continue
      </Button>
    </Form>
  )
}

```

### Sizes and variants [#sizes-and-variants]

Small, default, and large heights match Input and Select. The `text` variant drops the edge for toolbars; disabled selects keep their value visible.

```tsx
import {
  NativeSelect,
  NativeSelectOption,
} from "@/components/honest-ui/ui/native-select"

const sizes = ["sm", "default", "lg"] as const

export function NativeSelectSizes() {
  return (
    <div className="flex w-full max-w-64 flex-col gap-[var(--hui-space-4)]">
      {sizes.map((size) => (
        <NativeSelect
          key={size}
          size={size}
          aria-label={`Rows per page, ${size} size`}
          defaultValue="25"
        >
          <NativeSelectOption value="10">10 rows</NativeSelectOption>
          <NativeSelectOption value="25">25 rows</NativeSelectOption>
          <NativeSelectOption value="50">50 rows</NativeSelectOption>
          <NativeSelectOption value="100">100 rows</NativeSelectOption>
        </NativeSelect>
      ))}
      <NativeSelect variant="text" aria-label="Sort order" defaultValue="newest">
        <NativeSelectOption value="newest">Newest first</NativeSelectOption>
        <NativeSelectOption value="oldest">Oldest first</NativeSelectOption>
      </NativeSelect>
      <NativeSelect disabled aria-label="Plan (locked)" defaultValue="team">
        <NativeSelectOption value="team">Team plan</NativeSelectOption>
      </NativeSelect>
    </div>
  )
}

```

## API reference [#api-reference]

`NativeSelect` accepts every native `<select>` prop except the numeric `size` attribute, plus:

| Prop               | Values                | Default   |
| ------------------ | --------------------- | --------- |
| `size`             | `sm`, `default`, `lg` | `default` |
| `variant`          | `outline`, `text`     | `outline` |
| `wrapperClassName` | string                | —         |

`className` styles the `<select>`; `wrapperClassName` styles the span that positions the chevron, which is where width utilities such as `max-w-64` belong. The select is rendered through Base UI's Field control, so `name`, `disabled`, and validation follow a surrounding Field. `NativeSelectOption` and `NativeSelectOptGroup` render plain `<option>` and `<optgroup>` elements. `nativeSelectVariants` is exported for custom compositions.
