Skip to main content

Combobox

A searchable dropdown with filtering, built on Base UI’s Combobox primitive.

Base UI Primitive

Built on @base-ui/react/combobox

Import

import { Combobox } from "@soft-ui/react/combobox"

Usage

import { Combobox } from "@soft-ui/react/combobox"
import { RiArrowDownSLine } from "@soft-ui/icons"

export default function Example() {
  return (
    <Combobox.Root>
      <Combobox.Input placeholder="Search..." />
      <Combobox.Trigger>
        <RiArrowDownSLine />
      </Combobox.Trigger>
      <Combobox.Portal>
        <Combobox.Positioner>
          <Combobox.Popup>
            <Combobox.List>
              <Combobox.Item value="apple">
                Apple
              </Combobox.Item>
              <Combobox.Item value="banana">
                Banana
              </Combobox.Item>
            </Combobox.List>
          </Combobox.Popup>
        </Combobox.Positioner>
      </Combobox.Portal>
    </Combobox.Root>
  )
}

Components

Combobox.Root

size
's' | 'm' | 'l'
default:"'m'"
Control size.
  • s: 32px min height
  • m: 36px min height
  • l: 40px min height
variant
'secondary' | 'tertiary'
default:"'secondary'"
Visual style variant.
  • secondary: Solid background
  • tertiary: Glass-morphic with backdrop blur
items
readonly ItemValue[]
Array of items for the combobox.
value
Value
Controlled value.
defaultValue
Value
Uncontrolled default value.
onValueChange
(value: Value) => void
Callback fired when value changes.
multiple
boolean
Enable multiple selection with chips.
disabled
boolean
Disables the combobox.
className
string
Additional CSS classes for the container.
unsafeClassName
string
Escape hatch for structural overrides.

Combobox.Input

placeholder
string
Placeholder text.
className
string
Additional CSS classes.

Combobox.Trigger

className
string
Additional CSS classes.
unsafeClassName
string
Escape hatch for structural overrides.

Combobox.Clear

Button to clear the current selection.
className
string
Additional CSS classes.

Combobox.Chips / Combobox.Chip / Combobox.ChipRemove

For multiple selection mode.
className
string
Additional CSS classes.

Combobox.Positioner

sideOffset
number
default:"4"
Distance from trigger.
collisionPadding
number
default:"8"
Padding from viewport edge.

Combobox.Item

value
string
Value of the item.
disabled
boolean
Disables the item.
className
string
Additional CSS classes.

Combobox.Empty

Displayed when no items match the filter.
className
string
Additional CSS classes.

Examples

Basic

import { Combobox } from "@soft-ui/react/combobox"
import { RiArrowDownSLine } from "@soft-ui/icons"

export default function Basic() {
  return (
    <Combobox.Root>
      <Combobox.Input placeholder="Search fruits..." />
      <Combobox.Trigger>
        <RiArrowDownSLine />
      </Combobox.Trigger>
      <Combobox.Portal>
        <Combobox.Positioner>
          <Combobox.Popup>
            <Combobox.List>
              <Combobox.Item value="apple">Apple</Combobox.Item>
              <Combobox.Item value="banana">Banana</Combobox.Item>
              <Combobox.Item value="cherry">Cherry</Combobox.Item>
            </Combobox.List>
            <Combobox.Empty>No results found</Combobox.Empty>
          </Combobox.Popup>
        </Combobox.Positioner>
      </Combobox.Portal>
    </Combobox.Root>
  )
}

Multiple Selection

import { Combobox } from "@soft-ui/react/combobox"
import { RiCloseLine } from "@soft-ui/icons"

export default function Multiple() {
  return (
    <Combobox.Root multiple>
      <Combobox.Chips>
        {(value) => (
          <Combobox.Chip key={value}>
            {value}
            <Combobox.ChipRemove>
              <RiCloseLine />
            </Combobox.ChipRemove>
          </Combobox.Chip>
        )}
      </Combobox.Chips>
      <Combobox.Input placeholder="Search..." />
      <Combobox.Portal>
        <Combobox.Positioner>
          <Combobox.Popup>
            <Combobox.List>
              <Combobox.Item value="apple">Apple</Combobox.Item>
              <Combobox.Item value="banana">Banana</Combobox.Item>
            </Combobox.List>
          </Combobox.Popup>
        </Combobox.Positioner>
      </Combobox.Portal>
    </Combobox.Root>
  )
}

Build docs developers (and LLMs) love