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,
  SelectItemContent,
  SelectTriggerGroup,
} from "@/components/ui/select";
<Select>
  <SelectTriggerGroup placeholder="Select a fruit" />
  <SelectContent>
    <SelectItemContent value="Apple">Apple</SelectItemContent>
  </SelectContent>
</Select>

Anatomy

<Select>   
  <SelectTriggerGroup />
  <SelectContent>
    <SelectGroup>
      <SelectGroupLabel />
      <SelectItemContent />
    </SelectGroup>
  </SelectContent> 
</Select>

Features

Item Aligned

Custom Trigger

Animate icon
Icon placement
Icon placement with alignItemWithTrigger
Change icon inside popup

Scrollable

Multiple selection

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

With Groups

Use SelectGroup and SelectGroupLabel to organize items into sections.

States

Disabled

Invalid

Cookbook

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

Form Integration

Choose your favorite fruit from the list below.

API Reference

Primitives

Base Select API Reference

Composite Components

SelectTriggerGroup

A high-level trigger component that combines the Trigger, Value, and Icon into a single styled element. It handles sizing, icons, and placeholder text automatically.

PropTypeDefaultDescription
size"default" | "sm" | "lg""default"Controls the height and padding of the trigger.
placeholderstring-Text to display when no value is selected.
indicatorIconReact.ReactNode<ChevronDownIcon />The indicator icon. If not provided, defaults to a chevron.
indicatorPlacement"start" | "end""end"Positions the indicator icon either at the start or end of the trigger.
childrenReactNode-The selected value content (usually passed automatically by the Root).
classNamestring-Additional CSS classes.
...propsBaseSelect.Trigger-Passes all other props to the underlying BaseSelect.Trigger.

SelectContent

A composite component that wraps the Portal , Positioner, Popup, List, and scroll buttons.

PropTypeDefaultDescription
side"top" | "right" | "bottom" | "left""bottom"The preferred side of the trigger to render the content.
align"start" | "center" | "end""start"The preferred alignment against the trigger.
sideOffsetnumber4The distance in pixels from the trigger.
alignOffsetnumber0An offset in pixels from the align edge.
alignItemWithTriggerbooleanfalseWhether the selected item should be aligned with the trigger.
childrenReactNode-The list of items (SelectItem or SelectItemContent).
classNamestring-Additional CSS classes for the popup container.
...propsBaseSelect.Popup-Passes all other props to the underlying BaseSelect.Popup.

SelectItemContent

A convenience component for list items. It combines the Item, ItemText, and ItemIndicator (check icon) into a single component, managing styles and layouts for selected states.

PropTypeDefaultDescription
valuestringRequiredThe value of the item to be submitted when selected.
disabledbooleanfalseWhen true, prevents the user from interacting with the item.
indicatorIconReact.ReactNode<CheckIcon />Custom icon to show when the item is selected.
indicatorPlacement"start" | "end""end"Positions the selection indicator icon.
childrenReactNode-The text label of the item.
classNamestring-Additional CSS classes.
...propsBaseSelect.Item-Passes all other props to the underlying BaseSelect.Item.