Select
Accessible dropdown select component built with Radix UI
Installation
Install the select component using the shadcn CLI:
npx shadcn@latest add https://tezosx-ui.vercel.app/registry/tezosx/select.jsonExamples
Basic
Simple select dropdown
<Select>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Select a theme" />
</SelectTrigger>
<SelectContent>
<SelectItem value="light">Light</SelectItem>
<SelectItem value="dark">Dark</SelectItem>
<SelectItem value="system">System</SelectItem>
</SelectContent>
</Select>With Label
Select with associated label
<div className="space-y-2">
<Label htmlFor="framework">Framework</Label>
<Select>
<SelectTrigger id="framework" className="w-full">
<SelectValue placeholder="Select a framework" />
</SelectTrigger>
<SelectContent>
<SelectItem value="next">Next.js</SelectItem>
<SelectItem value="react">React</SelectItem>
</SelectContent>
</Select>
</div>Controlled
Select with controlled state
Selected: None
const [value, setValue] = useState("");
<Select value={value} onValueChange={setValue}>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Select an option" />
</SelectTrigger>
<SelectContent>
<SelectItem value="option1">Option 1</SelectItem>
<SelectItem value="option2">Option 2</SelectItem>
</SelectContent>
</Select>With Groups
Organized options with labels and separators
<Select>
<SelectTrigger className="w-[280px]">
<SelectValue placeholder="Select a timezone" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>North America</SelectLabel>
<SelectItem value="est">Eastern Standard Time</SelectItem>
<SelectItem value="cst">Central Standard Time</SelectItem>
</SelectGroup>
<SelectSeparator />
<SelectGroup>
<SelectLabel>Europe & Africa</SelectLabel>
<SelectItem value="gmt">Greenwich Mean Time</SelectItem>
</SelectGroup>
</SelectContent>
</Select>Disabled
Disabled select and individual items
<Select disabled>
<SelectTrigger>
<SelectValue placeholder="Disabled" />
</SelectTrigger>
</Select>
<Select>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="option1">Option 1</SelectItem>
<SelectItem value="option2" disabled>Option 2</SelectItem>
</SelectContent>
</Select>API Reference
The Select component consists of multiple sub-components:
Select (Root)
Main component. Props: value, onValueChange, defaultValue, disabled
SelectTrigger
The button that opens the dropdown
SelectValue
Displays the selected value or placeholder
SelectContent
The dropdown content container
SelectItem
Individual selectable option
SelectGroup
Groups related items together
SelectLabel
Label for a group of items
SelectSeparator
Visual separator between groups
Accessibility
- • Built on Radix UI Select for full accessibility support
- • Keyboard navigation: Arrow keys to navigate, Enter to select, Escape to close
- • Screen reader support with proper ARIA attributes
- • Focus management and keyboard shortcuts
- • Supports disabled states for both trigger and items
- • Portal rendering ensures proper z-index stacking
- • Scrollable content with scroll buttons for long lists