Shadcn UI Components
Select
A select component that displays a list of options for the user to pick from. Built on Radix UI Select with full keyboard navigation.
Select Examples
Basic Select
Select with Label
Grouped Select
Scrollable Select
Installation
# The component is already installed at:
# src/components/ui/shadcn/select.tsx
Usage
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/shadcn/select'
export function SelectDemo() {
return (
<Select>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Select a fruit" />
</SelectTrigger>
<SelectContent>
<SelectItem value="apple">Apple</SelectItem>
<SelectItem value="banana">Banana</SelectItem>
<SelectItem value="orange">Orange</SelectItem>
</SelectContent>
</Select>
)
}
Components
| Component | Description |
|---|---|
| Select | The root component |
| SelectTrigger | The button that opens the dropdown |
| SelectValue | Displays the selected value |
| SelectContent | The dropdown content container |
| SelectItem | An individual option |
| SelectGroup | Groups related options |
| SelectLabel | Label for a group of options |