

<InteractiveDemo
  name="select"
  controls="[
  {
    type: 'string',
    name: 'label',
    defaultValue: 'Country',
  },
  {
    type: 'string',
    name: 'placeholder',
    defaultValue: 'Select a country',
  },
  {
    type: 'boolean',
    name: 'isDisabled',
    defaultValue: false,
  },
  {
    type: 'boolean',
    name: 'isInvalid',
    defaultValue: false,
  },
]"
/>

## Installation [#installation]

<CodeBlockTabs defaultValue="npm">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npx shadcn@latest add @dotui/select
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm dlx shadcn@latest add @dotui/select
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn dlx shadcn@latest add @dotui/select
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bun x shadcn@latest add @dotui/select
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## Usage [#usage]

Use `Select` to allow users to choose a single option from a collapsible list of options when space is limited.

```tsx
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
} from '@/components/ui/select'
```

```tsx
<Select>
  <SelectTrigger />
  <SelectContent>
    <SelectItem>Option 1</SelectItem>
    <SelectItem>Option 2</SelectItem>
  </SelectContent>
</Select>
```

## Composition [#composition]

Select is built on top of primitive components that you can use directly for full customization:

* `SelectTrigger` → wraps `Button`
* `SelectContent` → wraps `Popover` + `ListBox`
* `SelectItem` → re-exports `ListBoxItem`

When you need more control, you can compose the primitives directly:

```tsx
import { Select, SelectValue } from '@/components/ui/select'
import { Button } from '@/components/ui/button'
import { Popover } from '@/components/ui/popover'
import {
  ListBox,
  ListBoxItem,
  ListBoxSection,
  ListBoxSectionHeader,
} from '@/components/ui/list-box'
```

```tsx
<Select>
  <Button variant="outline">
    <SelectValue placeholder="Select provider" />
    <ChevronDownIcon />
  </Button>
  <Popover placement="bottom-start">
    <ListBox>
      <ListBoxSection>
        <ListBoxSectionHeader>AI Providers</ListBoxSectionHeader>
        <ListBoxItem id="openai">OpenAI</ListBoxItem>
        <ListBoxItem id="anthropic">Anthropic</ListBoxItem>
      </ListBoxSection>
    </ListBox>
  </Popover>
</Select>
```

This approach lets you:

* Use any `Button` variant or custom trigger
* Control `Popover` placement and behavior
* Add sections, headers, and custom `ListBoxItem` content
* Reuse the same primitives across `Select`, `Combobox`, `Menu`, etc.

## Examples [#examples]

<Examples>
  <Example name="select/demos/basic" />

  <Example name="select/demos/placeholder" />

  <Example name="select/demos/label" />

  <Example name="select/demos/description" />

  <Example name="select/demos/validation" />

  <Example name="select/demos/sections" />

  <Example name="select/demos/links" />

  <Example name="select/demos/disabled" />

  <Example name="select/demos/loading" />

  <Example name="select/demos/required" />

  <Example name="select/demos/uncontrolled" />

  <Example name="select/demos/controlled" />

  <Example name="select/demos/composition" />

  <Example name="select/demos/async-loading" />
</Examples>

## API Reference [#api-reference]

### Select [#select]

<Reference name="select" />

### SelectValue [#selectvalue]

<Reference name="select-value" />

### SelectContent [#selectcontent]

<Reference name="select-content" />
