PX-UI
Components

Combobox

A searchable dropdown component for selecting values with autocomplete functionality

Overview

The Combobox component combines a text input with a dropdown list, allowing users to search and select values with autocomplete functionality. It supports single and multiple selection, async data loading, and infinite scrolling.

Import

import { Combobox } from "@px-ui/core";

Usage

const [value, setValue] = useState<any>(null);

const fruits = [
  { value: "apple", label: "Apple" },
  { value: "banana", label: "Banana" },
  { value: "orange", label: "Orange" },
];

<Combobox.Root value={value} onValueChange={setValue}>
  <Combobox.Trigger>
    <Combobox.Value placeholder="Select a fruit" />
  </Combobox.Trigger>
  <Combobox.Content>
    <Combobox.List>
      {fruits.map((fruit) => (
        <Combobox.Item key={fruit.value} value={fruit}>
          {fruit.label}
        </Combobox.Item>
      ))}
    </Combobox.List>
  </Combobox.Content>
</Combobox.Root>

Examples

Searchable Trigger

Use a searchable trigger to allow users to type and filter options as they search.

const [value, setValue] = useState<any>(null);

<Combobox.Root value={value} onValueChange={setValue}>
  <Combobox.SearchableTrigger placeholder="Search countries..." />
  <Combobox.Content>
    <Combobox.List>
      {countries.map((country) => (
        <Combobox.Item key={country.value} value={country}>
          {country.label}
        </Combobox.Item>
      ))}
    </Combobox.List>
  </Combobox.Content>
</Combobox.Root>

Multiple Selection

Enable multi-select mode with chips to allow users to select multiple options.

const [value, setValue] = useState<any[]>([]);

<Combobox.Root multiple value={value} onValueChange={setValue}>
  <Combobox.ChipsTrigger placeholder="Select languages">
    {(item: any) => (
      <Combobox.Chip key={item.value}>
        {item.label}
      </Combobox.Chip>
    )}
  </Combobox.ChipsTrigger>
  <Combobox.Content>
    <Combobox.List>
      {languages.map((language) => (
        <Combobox.MultiItem key={language.value} value={language}>
          {language.label}
        </Combobox.MultiItem>
      ))}
    </Combobox.List>
  </Combobox.Content>
</Combobox.Root>

With Search Field

Add a dedicated search field within the dropdown for better filtering of large lists.

<Combobox.Root value={value} onValueChange={setValue}>
  <Combobox.Trigger>
    <Combobox.Value placeholder="Select a user" />
  </Combobox.Trigger>
  <Combobox.Content>
    <Combobox.Search placeholder="Search users..." />
    <Combobox.List>
      {users.map((user) => (
        <Combobox.Item key={user.value} value={user}>
          {user.label}
        </Combobox.Item>
      ))}
    </Combobox.List>
  </Combobox.Content>
</Combobox.Root>

Anatomy

Components that make up Combobox:

Combobox.Root

The root container that manages combobox state and coordinates all combobox components.

Custom Props:

PropTypeDefaultDescription
valueValue | Value[]-Selected value(s)
onValueChange(value) => void-Callback when selection changes
multiplebooleanfalseEnable multi-select mode
disabledbooleanfalseWhether the combobox is disabled
invalidbooleanfalseWhether the combobox is in an invalid state
isLoadingbooleanfalseWhether options are loading
loadOptionsLoadOptionsConfig-Async options loading configuration

Inherited Props: Inherits all props from Base UI Combobox.Root


Combobox.Trigger

Button that opens the combobox dropdown when clicked.

Custom Props:

PropTypeDefaultDescription
size"sm" | "md" | "lg""md"Size of the trigger button
widthVariant"fit" | "enforced" | "full""enforced"Width behavior of the trigger
classNamestring-Additional CSS classes

Inherited Props: Inherits all props from Base UI Combobox.Trigger


Combobox.SearchableTrigger

Input-based trigger that allows typing to search and filter options.

Custom Props:

PropTypeDefaultDescription
placeholderstring-Placeholder text for the input
size"default" | "sm""default"Size of the input
widthVariant"enforced" | "fit" | "full""full"Width behavior
addonsReactNode-Additional addons for the input
classNamestring-Additional CSS classes

Combobox.ChipsTrigger

Multi-select trigger that displays selected values as removable chips.

Custom Props:

PropTypeDefaultDescription
placeholderstring-Placeholder when no values selected
childrenfunction-Render function for each chip
size"default" | "sm""default"Size of the trigger
widthVariant"enforced" | "full""enforced"Width behavior
classNamestring-Additional CSS classes

Combobox.Value

Displays the currently selected value or placeholder text.

Custom Props:

PropTypeDefaultDescription
placeholderstring-Text to show when no value is selected
childrenReactNode | function-Custom render function for the value
classNamestring-Additional CSS classes

Combobox.Content

The dropdown content container with positioning and animations.

Custom Props:

PropTypeDefaultDescription
emptystring"No options"Text to show when no options match
widthVariant"trigger" | "fit" | "enforced""trigger"Width behavior
portalPropsobject-Props for the portal component
positionerPropsobject-Props for the positioner component
popupPropsobject-Props for the popup component

Combobox.List

Container for combobox items, handles scrolling and keyboard navigation.

Inherited Props: Inherits all props from Base UI Combobox.List


Combobox.Item

Individual selectable option in the dropdown.

Custom Props:

PropTypeDefaultDescription
valueany-Value of this option
disabledbooleanfalseWhether the option is disabled
classNamestring-Additional CSS classes

Inherited Props: Inherits all props from Base UI Combobox.Item


Combobox.MultiItem

Item component for multi-select mode with checkbox indicator.

Custom Props:

PropTypeDefaultDescription
valueany-Value of this option
disabledbooleanfalseWhether the option is disabled
classNamestring-Additional CSS classes

Combobox.Chip

Chip component for displaying selected values in multi-select mode.

Custom Props:

PropTypeDefaultDescription
classNamestring-Additional CSS classes

Inherited Props: Inherits all props from Base UI Combobox.Chip


Combobox.Search

Dedicated search input field within the dropdown for filtering options.

Custom Props:

PropTypeDefaultDescription
placeholderstring"Search options"Placeholder text

Inherited Props: Inherits all props from Base UI Combobox.Input


API Reference

See the Anatomy section above for detailed component props.