GitHub

Combobox

Combines a text input with a listbox, allowing users to filter a list of options to items matching a query.

Docs

Installation

npx solidui-cli@latest add combobox

Usage

import {
  ComboboxContent,
  ComboboxControl,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxItemLabel,
  ComboboxRoot,
  ComboboxSection,
  ComboboxTrigger
} from "~/registry/ui/combobox"
const ALL_OPTIONS = ["Apple", "Banana", "Blueberry", "Grapes", "Pineapple"]
 
<ComboboxRoot
  options={ALL_OPTIONS}
  placeholder="Search a fruit..."
  itemComponent={(props) => (
    <ComboboxItem item={props.item}>
      <ComboboxItemLabel>{props.item.rawValue}</ComboboxItemLabel>
      <ComboboxItemIndicator />
    </ComboboxItem>
  )}
>
  <ComboboxControl aria-label="Fruit">
    <ComboboxInput />
    <ComboboxTrigger />
  </ComboboxControl>
  <ComboboxContent />
</ComboboxRoot>