Select

Displays a list of options for the user to select with a dropdown menu.

inputs
form
dropdown
selection

Preview

Variants

Basic select with a list of options.

Code

TSX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import {
      Select,
      SelectContent,
      SelectItem,
      SelectTrigger,
      SelectValue,
    } from "@/components/ui/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="blueberry">Blueberry</SelectItem>
            <SelectItem value="grapes">Grapes</SelectItem>
            <SelectItem value="pineapple">Pineapple</SelectItem>
          </SelectContent>
        </Select>
      )
    }

API Reference

PropTypeDefaultDescription
defaultValuestring-The value of the select when initially rendered.
valuestring-The controlled value of the select.
onValueChangefunction-Event handler called when the value changes.
disabledbooleanfalseWhen true, prevents the user from interacting with the select.
placeholderstring-The placeholder text for the select trigger.