Skip to content
shadcn.io
shadcn.io is not affiliated with official shadcn/ui

Shadcn Select for React and Tailwind

Displays a list of options.

Installation

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

Anatomy

Select
├── SelectTrigger
│   └── SelectValue
└── SelectContent
    ├── SelectEmpty
    ├── SelectClearTrigger
    ├── SelectGroup
    │   ├── SelectGroupLabel
    │   └── SelectItem
    └── SelectItem

Usage

import { createListCollection } from "@ark-ui/react/collection";
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select";
const collection = createListCollection({
  items: ["Option 1", "Option 2", "Option 3"],
});

<Select collection={collection}>
  <SelectTrigger>
    <SelectValue placeholder="Select an option" />
  </SelectTrigger>
  <SelectContent>
    {collection.items.map((item) => (
      <SelectItem item={item} key={item}>
        {item}
      </SelectItem>
    ))}
  </SelectContent>
</Select>

Controlled

Use value and onValueChange to control the selected items.

Size

Control trigger size with the size prop on SelectTrigger.

Small

Medium

Large

States

Disabled

Invalid

Examples

Multiple

Enable multiple selection with the multiple prop.

Grouping

Organize options into groups using groupBy and SelectGroup.

With Field

Use Field for labels, helper text, and error handling.

Max Selection

Scrollable

Empty

Use SelectEmpty to display a message when the collection has no items.

API Reference

Select

Root component.

PropTypeDefault
collectionListCollection<T>-
valuestring[]-
defaultValuestring[]-
onValueChange(details: ValueChangeDetails<T>) => void-
multiplebooleanfalse
disabledboolean-
invalidboolean-
namestring-
requiredboolean-
positioningPositioningOptions-
lazyMountbooleantrue
unmountOnExitbooleantrue
classNamestring-

SelectTrigger

Opens the dropdown on click. Displays the selected value or placeholder.

PropTypeDefault
size"sm" | "md" | "lg""md"
showClearbooleanfalse
classNamestring-
asChildboolean-

SelectValue

Shows the selected value or placeholder. Use SelectContext as children for custom display.

PropTypeDefault
placeholderstring-
classNamestring-
asChildboolean-

SelectContent

Holds the dropdown options. Displayed in a portal.

PropTypeDefault
classNamestring-
asChildboolean-

SelectClearTrigger

Button to clear the selected value. Shown when showClear is true on SelectTrigger.

PropTypeDefault
classNamestring-
asChildboolean-

SelectGroup

Groups related options under an optional heading.

PropTypeDefault
headingstring | ReactNode-
classNamestring-
asChildboolean-

SelectGroupLabel

Label for an option group.

PropTypeDefault
classNamestring-
asChildboolean-

SelectItem

A single selectable option in the dropdown.

PropTypeDefault
itemT-
classNamestring-
asChildboolean-

SelectEmpty

Shown when the collection has no items (collection.size === 0). Place inside SelectContent.

PropTypeDefault
classNamestring-

For a complete list of props, see the Ark UI documentation.