Combobox

The React Combobox component combines an input field with a dropdown list, allowing users to search and select an option. It lets users type to filter results and quickly find what they need.

It is useful when you have a large list of options. For example, users can search for a country, user, or category instead of scrolling through a long list. It also supports selecting multiple options with MultiCombobox, with selected items displayed as tags.

Built with React Aria Components ComboBox and styled using Tailwind CSS. It supports filtering, keyboard navigation, and accessible selection patterns.

Installation

Install the component using the Tailgrids CLI.

npx @tailgrids/cli@latest add combobox

Anatomy

Import the component and pass the required props.

import {
  Combobox,
  ComboboxInput,
  ComboboxItem,
  ComboboxList,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxTrigger
} from "@/components/tailgrids/combobox";

export default function ComboboxExample() {
  return (
    <Combobox aria-label="Fruit">
      <ComboboxInput placeholder="Select fruit">
        <ComboboxTrigger />
      </ComboboxInput>
      <ComboboxContent>
        <ComboboxList>
          <ComboboxItem id="apple">Apple</ComboboxItem>
          <ComboboxItem id="banana">Banana</ComboboxItem>
        </ComboboxList>
        <ComboboxEmpty>No results found</ComboboxEmpty>
      </ComboboxContent>
    </Combobox>
  );
}

Examples

With Label and Description

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

Choose the language you use most often.

Sections

Group related items together using ComboboxGroup and ComboboxLabel.

Multi Selection

The MultiCombobox component allows users to select multiple options, which are displayed as tags.

apple

Controlled

Manage the selection state externally using the value and onChange props.

Selected: 2 items

applebanana

Validation

Mark the combobox as required and display error messages using FieldError from the field component.

Please select a framework to continue.

Disabled

Disable the entire component or individual items to prevent user interaction.

With Avatars

Display items with avatars and secondary text for a more informative selection experience.

With Icons

Use icons to visually represent categories or types within the combobox.

Custom Tag Rendering

The MultiCombobox component can be customized to render selection tags with different styles.

Command Palette

A minimalist, search-focused design that can be used as a command palette with keyboard shortcut hints.

API Reference

Combobox

The root component that manages the selection state and coordinates between the input and the listbox.

PropTypeDefaultDescription
valueKey-The currently selected key (controlled).
defaultValueKey-The initial selected key (uncontrolled).
onChange(key: Key) => void-Handler that is called when the selection changes.
allowsEmptyCollectionbooleantrueWhether the combobox allows an empty collection.
itemsIterable<T>-The items to display in the combobox.
isDisabledboolean-Whether the combobox is disabled.
isInvalidboolean-Whether the combobox is in an invalid state.
isRequiredboolean-Whether the combobox is required.
classNamestring-Additional CSS classes to apply to the combobox container.

ComboboxInput

Renders the input group: the text field where users type to filter options. Render ComboboxTrigger as its child to add the toggle button.

PropTypeDefaultDescription
childrenReactNode-Elements shown at the end of the group, such as ComboboxTrigger.
classNamestring-Additional CSS classes to apply to the input field.

ComboboxTrigger

The button that toggles the visibility of the listbox.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the trigger button.

ComboboxContent

The popover container that holds the listbox of options.

PropTypeDefaultDescription
isNonModalbooleanfalseWhether the popover should be non-modal (doesn't block interaction).
placementPlacement-The placement of the popover relative to the trigger.
offsetnumber-The distance between the trigger and the popover.
crossOffsetnumber-The distance along the trigger's edge.
childrenReactNode-The content to be rendered within the popover.
classNamestring-Additional CSS classes to apply to the popover content.

ComboboxList

The listbox component that renders the collection of items.

PropTypeDefaultDescription
renderEmptyState() => Node-A function that returns the content to display when the collection is empty.
classNamestring-Additional CSS classes to apply to the list content.

ComboboxEmpty

A convenience component to display a message when no results are found. Should be placed inside ComboboxContent.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the empty message.

ComboboxItem

An individual option within the listbox.

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.

ComboboxGroup

A container for grouping related items within the listbox.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the section container.

ComboboxLabel

The heading for a group of items.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the header.

ComboboxValue

Renders the currently selected value(s) from React Aria ComboBoxValue.

PropTypeDefaultDescription
childrenReactNode | ((props: ComboBoxValueRenderProps<T>) => ReactNode)-Custom render function or fallback content.

ComboboxSeparator

Visual divider between groups or items. Extends React Aria Separator props.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the separator.

ComboboxCollection

Re-export of React Aria Collection for rendering dynamic item lists inside ComboboxList or ComboboxGroup.

ComboboxChips

Multi-select input container that wraps selected chips and ComboboxChipsInput. Extends React Aria Group props.

PropTypeDefaultDescription
childrenReactNode-ComboboxChipList and ComboboxChipsInput.
classNamestring-Additional CSS classes to apply to the container.

ComboboxChipList

Renders the list of selected items inside ComboboxChips. Extends React Aria ComboBoxValue props.

PropTypeDefaultDescription
childrenReactNode | ((props: ComboBoxValueRenderProps<T>) => ReactNode)-Render function or elements for each selected chip.

ComboboxChip

An individual removable chip/tag representing a selected item. Extends React Aria Tag props.

PropTypeDefaultDescription
childrenReactNode-Label content rendered inside the chip.
classNamestring-Additional CSS classes to apply to the chip.

ComboboxChipsInput

Text input placed inside ComboboxChips for filtering options in multi-select mode. Extends React Aria Input props.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the input.

MultiCombobox

A specialized combobox for selecting multiple values. Accepts all Combobox props except selectionMode (fixed to 'multiple'), with array-based value, defaultValue, and onChange.

PropTypeDefaultDescription
valueKey[]-The currently selected keys (controlled).
defaultValueKey[]-The initial selected keys (uncontrolled).
onChange(keys: Key[]) => void-Handler that is called when the selection changes.
onSelectionChange(key: Key | null) => void-Handler called when an individual item is selected.
itemsIterable<T>-The items to display in the combobox.
allowsEmptyCollectionbooleantrueWhether the combobox allows an empty collection.
isDisabledboolean-Whether the combobox is disabled.
isInvalidboolean-Whether the combobox is in an invalid state.
isRequiredboolean-Whether the combobox is required.
classNamestring-Additional CSS classes to apply to the container.

MultiComboboxDisplay

Renders the selected items as removable tags above or below MultiCombobox. Extends HTMLAttributes<HTMLDivElement>.

PropTypeDefaultDescription
renderTag(key: Key) => Node-Custom tag renderer.
classNamestring-Additional CSS classes to apply to the tags container.

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

Accessibility

  • Keyboard support: Users can navigate options using Arrow keys, select an option with Enter, and close the list with Escape.
  • Search and filtering: As users type in the input, the list updates to show matching results.
  • Focus management: Focus stays on the input while users navigate the list.
  • Selection behavior: Supports single and multiple selection depending on configuration.
  • Label and description: Provide a label and optional description so users understand the purpose of the input.