120k

Select

Displays a list of options for the user to pick from—triggered by a button.

Installation

pnpm dlx shadcn@latest add @force-ui-ember/select

Usage

import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from '@/ui/select';
<Select>
  <SelectTrigger @class="w-[180px]">
    <SelectValue @placeholder="Theme" />
  </SelectTrigger>
  <SelectContent>
    <SelectItem @value="light">Light</SelectItem>
    <SelectItem @value="dark">Dark</SelectItem>
    <SelectItem @value="system">System</SelectItem>
  </SelectContent>
</Select>

Composition

Use the following composition to build a Select:

Select
├── SelectTrigger
│   └── SelectValue
└── SelectContent
    ├── SelectGroup
    │   ├── SelectLabel
    │   ├── SelectItem
    │   └── SelectItem
    ├── SelectSeparator
    └── SelectGroup
        ├── SelectLabel
        ├── SelectItem
        └── SelectItem

Examples

Align Item With Trigger

Use the position prop on SelectContent to control alignment. When position="item-aligned" (default), the popup positions so the selected item appears over the trigger. When position="popper", the popup aligns to the trigger edge.

Groups

Use SelectGroup, SelectLabel, and SelectSeparator to organize items.

Scrollable

A select with many items that scrolls.

Disabled

Invalid

Add the data-invalid attribute to the Field component and the aria-invalid attribute to the SelectTrigger component to show an error state.

<Field data-invalid>
  <FieldLabel>Fruit</FieldLabel>
  <SelectTrigger aria-invalid="true">
    <SelectValue />
  </SelectTrigger>
</Field>

RTL

To enable RTL support in Force UI, see the RTL configuration guide.

API Reference

See the Radix UI Select documentation.