Select

A dropdown component that allows users to choose from a list of options.

Overview

The Select component provides a dropdown interface for choosing from a list of options, with support for grouping, clearing, custom indicators, and advanced rendering. Built on Base UI primitives, it offers full keyboard navigation and accessibility features out of the box.

Usage

import {
  Select,
  SelectClear,
  SelectContent,
  SelectGroup,
  SelectIndicator,
  SelectItem,
  SelectLabel,
  SelectSeparator,
  SelectTrigger,
  SelectValue,
} from "@tilt-legal/cubitt-components/select";
// Basic select
const fruitItems = [
  { label: "Apple", value: "apple" },
  { label: "Banana", value: "banana" },
  { label: "Cherry", value: "cherry" },
];

<Select items={fruitItems}>
  <SelectTrigger>
    <SelectValue placeholder="Select a fruit" />
  </SelectTrigger>
  <SelectContent>
    {fruitItems.map((item) => (
      <SelectItem key={item.value} value={item.value}>
        {item.label}
      </SelectItem>
    ))}
  </SelectContent>
</Select>

Pass items whenever you rely on the default <SelectValue /> output. Without that label map, the trigger can only fall back to raw values.

Examples

States

Select triggers in their default, error, disabled, and readonly states.

Indicator Position

Move the selection indicator to the left side.

With Clear Button

Add a clear button to reset the selection.

With Groups

Organize related options into labeled groups with separators.

Destructive Item

Use the destructive variant when one option represents a dangerous choice inside an otherwise standard select list.

Multiple Selection

Enable multi-select mode. Labels are automatically rendered from the items prop.

Size Variants

The select trigger supports three size variants: sm, md (default), and lg.

With Status Indicators

Display items with colored status dots.

With Icons

Display items with custom icons.

With Descriptions

Display items with labels and descriptions, plus custom indicators.

With Avatars

Display items with user avatars.

With Badges

Display items as badge components for statuses.

Scrollable Content

Handle long lists with scrollable content.

URL State (Single Select)

Sync a single selection with the URL. Try selecting a category and refreshing the page.

URL State (Multi-Select)

Sync multiple selections with the URL using comma-separated values.

API Reference

Select

The root component that provides context for all child components.

PropTypeDefaultDescription
items{ label: ReactNode, value: string }[]—Label/value pairs used by the trigger display. Pass this whenever you want the default SelectValue to render labels instead of raw values.
valuestring | string[] | null—The controlled value of the select.
defaultValuestring | string[] | null—The default value when uncontrolled.
onValueChange(value: string | string[] | null) => void—Callback when the selection changes.
multiplebooleanfalseEnable multi-select mode. When true, value/defaultValue should be arrays.
disabledbooleanfalseDisable the select component.
readOnlybooleanfalseMake the select read-only (user cannot change selection).
openboolean—Control the open state of the dropdown.
defaultOpenbooleanfalseThe default open state when uncontrolled.
onOpenChange(open: boolean) => void—Callback when the open state changes.
namestring—The name for form submission.
requiredbooleanfalseWhether the select is required in forms.
indicatorPosition"left" | "right""right"Position of the selection indicator within items.
indicatorVisibilitybooleantrueWhether to show the selection indicator.
indicatorReactNode—Custom indicator component to replace the default checkmark.
iconReactNode—Custom icon for the trigger button (replaces default chevron).
invalidbooleanfalseApplies invalid styling and sets aria-invalid on the trigger.
aria-invalidAriaAttributes['aria-invalid']—Forwarded to the trigger; values true, "grammar", or "spelling" are treated as invalid.
aria-describedbystring—Forwarded to the trigger (useful for error message ids).
classNamestring—Additional CSS classes for the select root.

URL State Props

When provided with a paramName, the select will sync its value with URL parameters via TanStack Router search params.

PropTypeDefaultDescription
paramNamestring—URL parameter name for syncing state with URL. Enables URL state management.
onUrlValueChange(value: string | string[] | null) => void—Callback when URL parameter value changes.
paramClearOnDefaultbooleantrueRemove URL param when value equals default.
paramThrottlenumber—Throttle URL updates in milliseconds.
paramDebouncenumber—Debounce URL updates in milliseconds.

SelectTrigger

The button that toggles the select dropdown. The default chevron uses Base UI's data-popup-side state so flipped or side-positioned popups keep the icon direction aligned with the popup.

PropTypeDefaultDescription
size"sm" | "md" | "lg""md"The size variant of the trigger.
classNamestring—Additional CSS classes for the trigger.
idstring—ID for linking with labels.

SelectValue

Displays the selected value or placeholder text. When the items prop is provided on the Select root, labels are automatically rendered. For complex displays (icons, avatars, badges), provide a render function as children.

PropTypeDefaultDescription
placeholderstring—Text to display when no value is selected.
classNamestring—Additional CSS classes for the value.
childrenReactNode | ((value: string | string[] | null) => ReactNode)—Custom render function for complex displays. Receives the current value and should return React elements.

SelectContent

The dropdown panel that contains the select options.

PropTypeDescription
classNamestringAdditional CSS classes for the content shell.
listClassNamestringAdditional CSS classes for the scrollable list.

SelectItem

An individual option within the select dropdown.

PropTypeDescription
valuestringThe value this item represents.
disabledbooleanWhether the item is disabled.
classNamestringAdditional CSS classes for the item.

SelectGroup

Groups related select items together.

PropTypeDescription
classNamestringAdditional CSS classes for the group.

SelectLabel

A label for a group of select items.

PropTypeDescription
classNamestringAdditional CSS classes for the label.

SelectSeparator

A visual separator between groups or items.

PropTypeDescription
classNamestringAdditional CSS classes for the separator.

SelectClear

A button to clear the current selection. Must be positioned within the trigger.

PropTypeDescription
onClick() => voidHandler for clearing the selection.
classNamestringAdditional CSS classes for the clear button.

SelectIndicator

Custom indicator component to replace the default checkmark.

PropTypeDescription
classNamestringAdditional CSS classes for the indicator.
childrenReactNodeCustom indicator content.

On this page