Select

Displays a list of options for the user to pick from, triggered by a button. Built with React Aria Components' Select and styled with Tailwind CSS and the Tailgrids theme tokens. Labels, descriptions and error messages come from the shared Field parts (FieldLabel, FieldDescription, FieldError).

Installation

Install the component using the Tailgrids CLI.

npx @tailgrids/cli@latest add select

Anatomy

Import the component and pass the required props.

import {
  Select,
  SelectContent,
  SelectValue,
  SelectItem,
  SelectTrigger
} from "@/components/tailgrids/select";

export default function SelectExample() {
  return (
    <Select aria-label="Fruit" placeholder="Select a fruit">
      <SelectTrigger>
        <SelectValue />
      </SelectTrigger>
      <SelectContent>
        <SelectItem id="apple">Apple</SelectItem>
        <SelectItem id="banana">Banana</SelectItem>
        <SelectItem id="orange">Orange</SelectItem>
      </SelectContent>
    </Select>
  );
}

Examples

With label and description

Add a label and description with FieldLabel and FieldDescription from the field component.

Favorite AnimalChoose an animal that you like the most.

Sections

Group options with SelectGroup and SelectLabel. Use SelectSeparator to visually separate groups.

Controlled

You can control the value of the select component using the value and onChange props.

Selected animal: No animal selected

Multiple select

The Select component supports multiple selection using the selectionMode="multiple" prop. You can control the selection using value (an Iterable<Key> or Set<Key>) and onChange.

Select Fruits

Custom icon

The trigger renders its own chevron. Put any extra element, such as a leading icon, inside SelectTrigger.

Required

The isRequired prop marks the select as required. Use FieldError to display validation errors.

Select Country *

Custom values

You can pass custom content to SelectItem to create more complex menu items.

Controlled multiple

A controlled version of the multiple select example.

Programming Frameworks

Selected count: 1

Disabled

You can disable the entire select component or individual items using the isDisabled prop.

Disabled Item
Disabled Select

API Reference

Select

PropTypeDefaultDescription
selectionMode'single' | 'multiple''single'Whether single or multiple selection is enabled.
valueKey | Iterable<Key>-The currently selected key(s) (controlled).
onChange(value: any) => void-Handler that is called when the value changes.
itemsIterable<T>-The items to display in the select.
namestring-The name of the input element, used when submitting an HTML form.
isDisabledboolean-Whether the select is disabled.
isInvalidboolean-Whether the select is in an invalid state.
isRequiredboolean-Whether the select requires a value to be selected.
classNamestring-Additional CSS classes to apply to the select container.

The Key type supports string and number. See React Aria's Select for more details.

State Attributes

The Select component supports the following state attributes on its container:

AttributeDescription
data-focusedWhether the select is currently focused.
data-openWhether the select is currently open.
data-invalidWhether the select is in an invalid state.
data-disabledWhether the select is disabled.
data-requiredWhether the select is required.

SelectTrigger

PropTypeDefaultDescription
size'sm' | 'default''default'The size of the trigger.
classNamestring-Additional CSS classes to apply to the trigger button.

SelectContent

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the popover content.

SelectPopover

The underlying popover container used by SelectContent. Extends React Aria Popover props.

PropTypeDefaultDescription
placementPlacement-The placement of the popover relative to the trigger.
offsetnumber-Distance between the trigger and the popover.
crossOffsetnumber-Distance along the trigger's edge.
isNonModalbooleanfalseWhether the popover allows interaction outside without closing.
childrenReact.ReactNode-Content rendered inside the popover.
classNamestring-Additional CSS classes to apply to the popover.

SelectItem

PropTypeDefaultDescription
idstring | number-The unique identifier for the item.
textValuestring-A text representation of the item's content, used for keyboard navigation and accessibility.
isDisabledboolean-Whether the item is disabled.
classNamestring-Additional CSS classes to apply to the item.

SelectValue

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the selected value output.

SelectGroup, SelectLabel, SelectSeparator, SelectList, SelectInput, SelectEmpty

Each accepts className. SelectGroup groups items, SelectLabel is the group heading, SelectList renders the list box, SelectInput adds a search field and SelectEmpty shows content when nothing matches.

See React Aria's Select for more details.

Accessibility

  • Keyboard Navigation: Supports arrow keys to navigate options, Enter/Space to select, and Escape to close the menu.
  • Screen Reader Support: Uses ARIA attributes (e.g., aria-expanded, aria-activedescendant) to provide context to screen readers.
  • Labeling: Supports labeling via FieldLabel, aria-label or aria-labelledby.