Installation
npx logic2b@next add selectUsage
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
<Select>
<SelectTrigger aria-label="Select a fruit" className="w-[180px]">
<SelectValue placeholder="Select a fruit" />
</SelectTrigger>
<SelectContent>
<SelectItem value="apple">Apple</SelectItem>
</SelectContent>
</Select>
Examples
Grouped options
With a disabled option
Accessibility
Built on Radix Select, following the WAI-ARIA listbox pattern.
- Fully keyboard operable: open with Enter/Space/arrow keys, move with arrows, and type-ahead to jump to an option.
- Esc closes the list and focus returns to the trigger.
- Give
SelectTriggeran explicit accessible name witharia-labeloraria-labelledby;SelectValue’s placeholder communicates the empty state but does not replace the field name. - Group related options with
SelectGroup+SelectLabelfor clearer announcements.
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
Generated JSX
<Select
defaultValue="team"
>
<SelectTrigger
className="w-56"
aria-label="Workspace plan"
>
<SelectValue
placeholder="Choose a plan"
/>
</SelectTrigger>
<SelectContent>
<SelectItem
value="starter"
>Starter</SelectItem>
<SelectItem
value="team"
>Team</SelectItem>
<SelectItem
value="enterprise"
>Enterprise</SelectItem>
</SelectContent>
</Select>API reference
Generated from the public TypeScript exports in src/ui/select.tsx.
Select
ComponentProps: React.ComponentProps<typeof SelectPrimitive.Root>SelectContent
ComponentProps: React.ComponentProps<typeof SelectPrimitive.Content>| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
position | "item-aligned" | "popper" | No | "popper" | — |
SelectGroup
ComponentProps: React.ComponentProps<typeof SelectPrimitive.Group>SelectItem
ComponentProps: React.ComponentProps<typeof SelectPrimitive.Item>SelectLabel
ComponentProps: React.ComponentProps<typeof SelectPrimitive.Label>SelectScrollDownButton
ComponentProps: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>SelectScrollUpButton
ComponentProps: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>SelectSeparator
ComponentProps: React.ComponentProps<typeof SelectPrimitive.Separator>SelectTrigger
ComponentProps: React.ComponentProps<typeof SelectPrimitive.Trigger> & { size?: "sm" | "default" }| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
size | "sm" | "default" | No | "default" | — |
SelectValue
ComponentProps: React.ComponentProps<typeof SelectPrimitive.Value>Accessibility contract
Machine-readable behavior and consumer responsibilities for select.
- Support
- Primitive-managed
- Pattern
- listbox select
- Radix Select
| Keys | Behavior |
|---|---|
| Enter Space | Activate the focused control. |
| ArrowUp ArrowDown ArrowLeft ArrowRight | Move within the composite control. |
| Home End | Move to the first or last option. |
| Escape | Close the open surface and restore focus. |
Built-in semantics
- Manages combobox/listbox/option semantics, selected state and trigger-value linkage.
Consumer responsibilities
- Provide a visible label or aria-label for the trigger.