Select
Picks one value from a short, known list. Click and pick, no typing. Looks and sizes like Input.
Usage
pnpm dlx shadcn@latest add selectThen replace components/ui/select.tsx and add menu-styles.ts from the Matrix versions. The trigger matches Input (border, sizes, focus, error) and the list matches Dropdown menu.
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
<Select value={frequency} onValueChange={setFrequency}>
<SelectTrigger id="frequency"><SelectValue placeholder="Choose how often" /></SelectTrigger>
<SelectContent>
<SelectItem value="hourly">Every hour</SelectItem>
<SelectItem value="daily">Every day</SelectItem>
<SelectItem value="weekly">Every week</SelectItem>
</SelectContent>
</Select>If the list is long or people would rather type, use a combobox (coming later). If there are only 2–5 options that fit on screen, a Radio group is faster.
At a glance
The list opens below the trigger at the trigger's width, with a check at the end of the selected option.
Variants
For an optional value, put "None" first instead of adding a clear button to the trigger.
States
Sizes
Sizes match Input and Button. shadcn's size="default" still works (same as md).
Behavior
Opens below, at the trigger's width
The list sits under the trigger and is at least as wide as it; long option names make it wider. Keep option names short.
Keyboard
Space, Enter or the arrows open the list; arrows move, typing jumps to a matching option, Enter picks, Escape closes without changing anything.
Picking applies to the form
A select is a form value. If the change should apply immediately to a setting, that's still fine, but say so near the field.
API reference
Prop
Type
Guidelines
- Use a select for 5 to about 15 known options. Fewer: radio group. More, or searchable: combobox.
- Give it a visible label with Field.
- Pre-select a sensible default when one exists; use a placeholder only when people must actively choose.
- Don't use a select for actions; use a Dropdown menu.