GitHub

Select

Pick one or more values from a list—as a plain dropdown, a searchable list or a text input with suggestions.

Loading example…

Installation

pnpm dlx shadcn@latest add @sui/select

Install with the shadcn CLI or use the shared @workspace/ui package. Follow the installation guide to configure the registry, load styles, and choose import aliases.

Usage

import {
  Select,
  SelectContent,
  SelectGroup,
  SelectItem,
  SelectList,
  SelectTrigger,
  SelectValue,
} from "@workspace/ui/components/select"
const items = [
  { label: "Light", value: "light" },
  { label: "Dark", value: "dark" },
  { label: "System", value: "system" },
]

<Select items={items}>
  <SelectTrigger className="w-[180px]">
    <SelectValue placeholder="Theme" />
  </SelectTrigger>
  <SelectContent>
    <SelectList>
      {items.map((item) => (
        <SelectItem key={item.value} value={item.value}>
          {item.label}
        </SelectItem>
      ))}
    </SelectList>
  </SelectContent>
</Select>

Composition

Select takes its shape from the parts you put in it. Every shape shares SelectContent, SelectList and SelectItem.

Select
├── SelectTrigger            ← plain dropdown
│   └── SelectValue
├── SelectInput              ← text input as the trigger
├── SelectChips              ← multiple values as chips
│   ├── SelectChip
│   └── SelectChipsInput
└── SelectContent
    ├── SelectSearch         ← search box inside the popup
    ├── SelectEmpty
    └── SelectList
        ├── SelectGroup
        │   ├── SelectLabel
        │   └── SelectItem
        ├── SelectSeparator
        └── SelectItem

Searchable

The popup has no search box until you add one: put SelectSearch inside SelectContent to filter the list. Static SelectItem children are filtered too when Select has items. Without it the arrow keys and Enter still work.

Loading example…

Input

Use SelectInput outside SelectContent to make the text input the trigger.

Loading example…

Clear

Add showClear to SelectInput to show a button that clears the value.

Loading example…

Multiple

Set multiple on Select and show the values with SelectChips. Pass the anchor from useSelectAnchor to SelectContent so the popup lines up with the chips.

Loading example…

Free Text

Control inputValue to keep whatever the user types, including text that matches no item. The list only suggests.

Loading example…

Groups

Use SelectGroup, SelectLabel, and SelectSeparator to organize items.

Loading example…

With a search input, render groups from items with SelectCollection.

Loading example…

Scrollable

A select with many items that scrolls.

Loading example…

Disabled

Loading example…

Invalid

Add the data-invalid attribute to the Field component and the aria-invalid attribute to the SelectTrigger component to show an error state.

<Field data-invalid>
  <FieldLabel>Fruit</FieldLabel>
  <SelectTrigger aria-invalid>
    <SelectValue />
  </SelectTrigger>
</Field>
Loading example…

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

Loading example…

API Reference

Select is built on Base UI Combobox. See the Base UI Combobox documentation.