Component guideEditable source

Select

A single-choice dropdown with controlled or uncontrolled state.

Original component docs
On this page8 sectionsBack to top

Use Select for a compact list of predefined options. Give each SelectItem a stable value and display text. For searchable choices use Combobox.

Live preview
Loading preview...

#Installation

Complete the base setup. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/select.json

#Usage

"use client";
import { useState } from "react";
import {
  Select,
  SelectTrigger,
  SelectValue,
  SelectContent,
  SelectItem,
} from "@/components/ui/select";

const statuses = [
  { value: "draft", label: "Draft" },
  { value: "published", label: "Published" },
];

export default function PublicationStatus() {
  const [status, setStatus] = useState<string | null>("draft");
  return (
    <div className="grid max-w-sm gap-2">
      <label htmlFor="publication-status">Publication status</label>
      <Select items={statuses} value={status} onValueChange={setStatus}>
        <SelectTrigger id="publication-status">
          <SelectValue placeholder="Choose a status" />
        </SelectTrigger>
        <SelectContent>
          {statuses.map((option) => (
            <SelectItem key={option.value} value={option.value}>
              {option.label}
            </SelectItem>
          ))}
        </SelectContent>
      </Select>
      <p role="status">Selected: {status ?? "None"}</p>
    </div>
  );
}

#API reference

Prop / partPurposeDefault
Select.value / onValueChangeControlled string or null selection; receives Base UI event detailsUncontrolled
Select.defaultValueInitial selectionUnset
Select.itemsValue-to-label mapping or { value, label } array used by SelectValue to display the selected labelUnset
Select.name / required / disabledForm key and constraintsUnset / false / false
SelectTrigger.sizesm or defaultdefault
SelectValue.placeholderPrompt without selectionUnset
SelectItem.value / disabledOption value and availabilityValue required / false
SelectContent.side / alignPreferred popup placement and alignmentbottom / start
SelectContent.alignItemWithTriggerAlign the selected item over the triggerfalse
SelectContent.alignOffset / arrowPadding / collisionPaddingAlignment, arrow, and collision-boundary spacing, in pixels0
SelectContent.sideOffsetTrigger-to-popup gap, in pixels4

Pass the same options to Select.items and render their SelectItem elements, as in the Usage example. items supplies the selected display label; it does not render the popup options. Base UI 1.8 does not infer that label from SelectItem text. Labels can contain icons and text, and SelectValue also accepts a child function for custom display.

#Accessibility

Associate a visible label with the trigger. Keep option text meaningful without color or an icon. Verify arrow navigation, typeahead, Escape, and focus return. Selection is application state; this component does not save it to a server.

#Examples

#Large list

Loading preview...

#Disabled

Loading preview...

#With icon

Loading preview...