Select
Displays a list of options for the user to pick from.
Installation
Add the select component with the shadcn CLI.
npx shadcn@latest add https://yami.ui.unsanity.ai/r/select.jsonUsage
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
<Select defaultValue="next">
<SelectTrigger className="w-48">
<SelectValue placeholder="Framework" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>Frameworks</SelectLabel>
<SelectItem value="next">Next.js</SelectItem>
<SelectItem value="remix">Remix</SelectItem>
</SelectGroup>
</SelectContent>
</Select>Examples
Small
size=sm triggerCode
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
<Select defaultValue="next">
<SelectTrigger size="sm" className="w-40">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="next">Next.js</SelectItem>
<SelectItem value="remix">Remix</SelectItem>
</SelectContent>
</Select>Grouped
SelectGroup + SelectSeparatorCode
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectSeparator,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
<Select defaultValue="apple">
<SelectTrigger className="w-48">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>Fruits</SelectLabel>
<SelectItem value="apple">Apple</SelectItem>
<SelectItem value="banana">Banana</SelectItem>
</SelectGroup>
<SelectSeparator />
<SelectGroup>
<SelectLabel>Vegetables</SelectLabel>
<SelectItem value="carrot">Carrot</SelectItem>
<SelectItem value="pepper">Pepper</SelectItem>
</SelectGroup>
</SelectContent>
</Select>