Select

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

Saved preference for elorm init --ui-library base-ui
PreviewCode
"use client"

import {
  Select,
  SelectContent,
  SelectItem,
  SelectGroup,
  SelectLabel,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select"

export function SelectDemo() {
  return (
    <Select defaultValue="apple" aria-label="Select a fruit">
      <SelectTrigger className="w-[180px]">
        <SelectValue placeholder="Select a fruit" />
      </SelectTrigger>
      <SelectContent>
        <SelectGroup>
          <SelectLabel>Fruits</SelectLabel>
          <SelectItem value="apple">Apple</SelectItem>
          <SelectItem value="banana">Banana</SelectItem>
          <SelectItem value="blueberry">Blueberry</SelectItem>
          <SelectItem value="grapes">Grapes</SelectItem>
          <SelectItem value="pineapple">Pineapple</SelectItem>
        </SelectGroup>
      </SelectContent>
    </Select>
  )
}

Installation#

Usage#

import {
  Select,
  SelectContent,
  SelectGroup,
  SelectItem,
  SelectLabel,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select"

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

Wrap options in SelectGroup. Always include SelectValue in SelectTrigger.

Composition#

Select
├── Select
├── SelectTrigger
├── SelectValue
├── SelectContent
├── SelectGroup
├── SelectLabel
├── SelectItem