# Native Select

Displays a styled native select element.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).





<ComponentPreview name="native-select-demo">
  <NativeSelectDemo />
</ComponentPreview>

## Installation [#installation]

<Tabs defaultValue="cli">
  <TabsList>
    <TabsTrigger value="cli">
      CLI
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add https://shadcn-cssinjs.com/r/native-select.json
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      pnpm add @stylexjs/stylex
      ```

      <Step>
        Make sure [StyleX is configured](/docs/installation) and the design tokens are
        installed.
      </Step>

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource name="native-select" title="native-select.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</Tabs>

## Usage [#usage]

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

```tsx
<NativeSelect defaultValue="apple">
  <NativeSelectOption value="apple">Apple</NativeSelectOption>
  <NativeSelectOption value="banana">Banana</NativeSelectOption>
</NativeSelect>
```

## Composition [#composition]

Use the following composition to build a `NativeSelect`:

```txt
NativeSelect
├── NativeSelectOption
└── NativeSelectOptGroup
    └── NativeSelectOption
```

## Examples [#examples]

### Groups [#groups]

Use `NativeSelectOptGroup` to group related options.

<ComponentPreview name="native-select-demo">
  <NativeSelectDemo />
</ComponentPreview>

### Disabled [#disabled]

<ComponentPreview name="native-select-disabled">
  <NativeSelectDisabled />
</ComponentPreview>



### Invalid [#invalid]

Set `aria-invalid` to show an error state.

<ComponentPreview name="native-select-invalid">
  <NativeSelectInvalid />
</ComponentPreview>



## RTL [#rtl]

To enable right-to-left support, see the [RTL guide](/docs/rtl).

<ComponentPreview name="native-select-rtl" direction="rtl">
  <NativeSelectRtl />
</ComponentPreview>

## API Reference [#api-reference]

### NativeSelect [#nativeselect]

The main select component that wraps the native HTML `select` element and accepts all of its props.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` | -       |

### NativeSelectOption [#nativeselectoption]

Represents an individual option within the select.

| Prop       | Type      | Default |
| ---------- | --------- | ------- |
| `value`    | `string`  | -       |
| `disabled` | `boolean` | `false` |

### NativeSelectOptGroup [#nativeselectoptgroup]

Groups related options together for better organization.

| Prop       | Type      | Default |
| ---------- | --------- | ------- |
| `label`    | `string`  | -       |
| `disabled` | `boolean` | `false` |
