Combobox

A searchable dropdown with autocomplete, multi-select, and create-new functionality.

Installation

bash
npx @smicolon/cli add combobox

Run init once per project before adding components. See Installation.

Preview

Searchable

Multi-select

Creatable

States

Props

PropTypeDefaultDescription
optionsComboboxOption[]—Options to choose from.
valuestring | string[]—Selected value, or values when multiple.
onChange(value) => void—Called when the selection changes.
placeholderstring"Select option..."Text shown before a choice.
searchPlaceholderstring"Search..."Placeholder of the search field.
multiplebooleanfalseAllows several selections.
creatablebooleanfalseLets the user add a new option.
onCreate(value) => void—Called with the new option’s text.
emptyTextstring"No options found."Text when nothing matches.
createTextstring"Create"Label of the create option.
loadingbooleanfalseShows the loading state.
loadingTextstring"Loading..."Text shown while loading.
openLabelstring"Open"Toggle’s accessible name when closed.
closeLabelstring"Close"Toggle’s accessible name when open.
removeLabel(label) => string—Accessible name of a chip’s remove button.
disabledbooleanfalseDisables the combobox and dims it.
classNamestring—Extra classes for the component.

Usage

tsx
import { Combobox } from "@/components/ui/combobox"

const options = [
  { value: "sa", label: "Saudi Arabia" },
  { value: "ae", label: "United Arab Emirates" },
  { value: "eg", label: "Egypt" },
]

// Basic combobox
<Combobox
  options={options}
  placeholder="Select an option…"
/>

// Controlled with search
const [value, setValue] = useState("")

<Combobox
  options={options}
  value={value}
  onChange={setValue}
/>

// Multi-select
<Combobox
  options={options}
  multiple
  value={selectedValues}
  onChange={setSelectedValues}
/>

// Creatable
<Combobox
  options={options}
  creatable
  onCreate={(value) => {
    // Add new option to your list
  }}
/>