Select

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

Installation

pnpm dlx shadcn@latest add @lumi-ui/select

Basic Usage

import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select"
<Select>
  <SelectTrigger className="w-[180px]">
    <SelectValue placeholder="Theme" />
  </SelectTrigger>
  <SelectContent>
    <SelectItem value="light">Light</SelectItem>
    <SelectItem value="dark">Dark</SelectItem>
    <SelectItem value="system">System</SelectItem>
  </SelectContent>
</Select>

Recipes

Scrollable

When the content exceeds the viewport height, scroll buttons automatically appear.

With Groups

Use SelectGroup and SelectLabel to organize items into sections.

Multiple selection

Add the multiple prop to the <Select> component to allow multiple selections.

Item Aligned

Use position="item-aligned" for classic OS-style positioning where the selected item aligns with the trigger.

Disabled

Disable the entire select or individual items.

Data-Driven Items

Pass an array of objects to the items prop to automatically handle value-label lookups and rendering.

Custom Render

You can customize the rendered content while still using the items prop for accessibility.

Controlled

Control the value state programmatically.

Selected value: apple

Track State

You can track the state of the select and use it to display additional information.

Selected value: next

Anatomy

<Select>
  <SelectTrigger>
    <SelectValue />
  </SelectTrigger>
  <SelectContent>
    <SelectGroup>
      <SelectLabel />
      <SelectItem />
    </SelectGroup>
    <SelectSeparator />
  </SelectContent>
</Select>
ComponentRole
SelectRoot component that manages state and value.
SelectTriggerButton that toggles the dropdown.
SelectValueDisplays the selected value or placeholder.
SelectContentPopover container with positioning and scroll handling.
SelectGroupGroups related items together.
SelectLabelLabel for a group of items.
SelectItemIndividual selectable option.
SelectSeparatorVisual divider between items or groups.
SelectScrollUpButtonScroll control at the top of the list.
SelectScrollDownButtonScroll control at the bottom of the list.

Migration from shadcn/ui

Component Naming & Structure

Our component wraps Base UI's Select primitive but maintains shadcn/ui's naming convention for easy migration.

shadcn/uiLumi UINotes
SelectSelectSupports items and multiple props.
SelectTriggerSelectTriggerIdentical usage.
SelectValueSelectValueIdentical usage.
SelectContentSelectContentIdentical usage.
SelectItemSelectItemIdentical usage.
SelectGroupSelectGroupIdentical usage.
SelectLabelSelectLabelIdentical usage.

Key Differences & New Features

FeatureLumi UIshadcn/ui (Radix)
Label RenderingAutomatic via items propManual mapping required
Multi-selectNative multiple propRequires custom implementation
Positioningpopper or item-alignedMostly popper
ArrowOptional (removed by default)Included by default

Migration Example

<Select>
  <SelectTrigger>
    <SelectValue placeholder="Select a fruit" />
  </SelectTrigger>
  <SelectContent>
    <SelectItem value="apple">Apple</SelectItem>
    <SelectItem value="banana">Banana</SelectItem>
  </SelectContent>
</Select>