Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Select for React

Displays a list of options.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/radix/select.json

Anatomy

SelectRoot
├── SelectLabel
├── SelectClearTrigger
├── SelectItem
│   ├── SelectItemText
│   ├── SelectItemIndicator
│   └── SelectGroup
│       └── SelectGroupLabel
├── SelectList
├── SelectContent
│   └── SelectPositioner
├── SelectTrigger
│   └── SelectIndicator
└── SelectValue

Usage

import { createListCollection } from "@ark-ui/react/collection";
import {
  Select,
  SelectContent,
  SelectGroup,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select";
const items = [
  { label: "Apple", value: "apple" },
  { label: "Banana", value: "banana" },
  { label: "Blueberry", value: "blueberry" },
];

const collection = createListCollection({ items });

const SelectDemo = () => (
  <Select collection={collection}>
    <SelectTrigger className="w-48">
      <SelectValue placeholder="Select a fruit" />
    </SelectTrigger>
    <SelectContent>
      <SelectGroup>
        {collection.items.map((item) => (
          <SelectItem item={item} key={item.value}>
            {item.label}
          </SelectItem>
        ))}
      </SelectGroup>
    </SelectContent>
  </Select>
);

Accessibility

KeyDescription
Enter
Activate the focused control.
Space
Activate the focused control.
ArrowUp
Move up.
ArrowDown
Move down.
ArrowLeft
Move left.
ArrowRight
Move right.
Home
Go to the start.
End
Go to the end.

Demos

Align Item

Use data-align-trigger on SelectContent to mirror Base UI alignItemWithTrigger (selected item over the trigger vs edge-aligned).

Groups

Use SelectGroup, group headings, and SelectSeparator to organize items.

Scrollable

A select with many items that scrolls.

Disabled

A disabled select.

Invalid

Add data-invalid on Field and aria-invalid on SelectTrigger for the error state.

Rtl

Right-to-left select. See the RTL configuration guide for document direction.

API Reference

SelectLabel

label

PropType
AttributeType

SelectTrigger

button

PropType
AttributeType

SelectItem

div

PropType
valuestring
disabled?boolean
textValue?string
AttributeType

SelectItemText

span

AttributeType

SelectItemIndicator

div

AttributeType

SelectContent

div

PropType
AttributeType
data-align-trigger?string
CSS variableType
--radix-select-content-available-heightstring
--radix-select-content-transform-originstring
--radix-select-trigger-heightstring
--radix-select-trigger-widthstring

Select

div

PropType
AttributeType

SelectGroup

PropType
AttributeType

SelectValue

PropType
placeholder?React.ReactNode
AttributeType

SelectSeparator

PropType
AttributeType

SelectScrollUpButton

PropType
AttributeType

SelectScrollDownButton

PropType
AttributeType