Skip to content

Select

A common form component for choosing a predefined value in a dropdown menu.

API Reference

Installation

pnpm dlx shadcn@latest add @frontal-labs/select

Usage

import {
  Select,
  SelectContent,
  SelectGroup,
  SelectItem,
  SelectLabel,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select";
const items = [
  { label: "Select framework", value: null },
  { label: "Next.js", value: "next" },
  { label: "Vite", value: "vite" },
  { label: "Astro", value: "astro" },
]
 
<Select items={items}>
  <SelectTrigger>
    <SelectValue />
  </SelectTrigger>
  <SelectContent>
    <SelectGroup>
      <SelectLabel>Frameworks</SelectLabel>
      {items.map((item) => (
        <SelectItem key={item.value} value={item}>
          {item.label}
        </SelectItem>
      ))}
    </SelectGroup>
  </SelectContent>
</Select>

API Reference

Select

Root component. Alias for Select.Root from Base UI.

SelectTrigger

Trigger button that opens the select dropdown. Styled wrapper for Select.Trigger from Base UI.

SelectValue

Displays the selected value. Styled wrapper for Select.Value from Base UI.

SelectContent

Popup container for select options. The surface is elevated with shadow-menu and surface-ring.

About dark: the popup renders with the dark palette by default. Pass dark={false} when it should follow the ambient theme instead — next-themes sets dark on <html> and the portal lands in document.body, inside it, so the popup can pick up the ambient theme once dark is turned off. For a popup opened from a .dark region scoped mid-page, which a portal does escape, rendering into the scoped node is usually the better tool. dark applies .dark to the positioner inside the portal, so the tokens inherit down to the popup and everything within it.

SelectScrollUpButton

Scroll affordance rendered at the top of the popup when the list overflows.

SelectScrollDownButton

Scroll affordance rendered at the bottom of the popup when the list overflows.

SelectItem

Individual select option. Styled wrapper for Select.Item from Base UI with built-in indicator.

SelectGroup

Groups related select items. Alias for Select.Group from Base UI.

SelectLabel

Label for a select group. Styled wrapper for Select.GroupLabel from Base UI. Place it inside a SelectGroup.

SelectSeparator

Visual separator between items. Styled wrapper for Select.Separator from Base UI.

Examples

For accessible labelling and validation, prefer using the Field component to wrap selects. See the related example: Select field.

Small Size

Large Size

Disabled

Without Item Alignment

With Groups

With Label

Multiple Selection

With Icon

Options with Icon

With Object Values

Select-like Combobox

Render a ComboboxTrigger with a Button to create a searchable combobox that reads like a select.

Form Integration