Select
A trigger and listbox for choosing one option.
Installation
npx shadcn@latest add @blank/selectUsage
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"<Select>
<SelectTrigger className="w-48">
<SelectValue placeholder="Theme" />
</SelectTrigger>
<SelectContent>
<SelectItem value="light">Light</SelectItem>
<SelectItem value="dark">Dark</SelectItem>
</SelectContent>
</Select>Examples
Sizes
32, 36 and 40 px on the same field surface as Input, so a trigger and a text field in one form match.
Below the trigger
The default item-aligned position lays the list over the trigger with the selected item on top of it, like a native menu. position="popper" drops it below instead, at the trigger's width.
Inverted
API Reference
Select
Every Radix Select.Root prop: value, defaultValue, onValueChange, open, onOpenChange, disabled, name.
SelectTrigger
Every Radix Select.Trigger prop, plus:
| Prop | Type | Default |
|---|---|---|
size | "sm" | "default" | "lg" | "default" |
SelectContent
Every Radix Select.Content prop, plus:
| Prop | Type | Default |
|---|---|---|
position | "item-aligned" | "popper" | "item-aligned" |
align | "start" | "center" | "end" | "center" |
inverted | boolean | false |
SelectItem
Every Radix Select.Item prop: value, disabled, textValue.