Search documentation

Search components and pages

Select

Displays a list of options for the user to pick from.

01

Installation

Add the select component with the shadcn CLI.

bash
npx shadcn@latest add https://swiss.ui.unsanity.ai/r/select.json
02

Usage

tsx
import { Select } from "@/components/ui/select"
03

Examples

Small

size=sm trigger
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 + SelectSeparator
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>