Officina UI
Components

Combobox

Searchable single-select with type-to-filter, keyboard navigation, and custom rendering.

Combobox is a single-select that filters its options as the user types and is navigable with the arrow keys, Enter, and Escape. It is controlled: value holds the chosen option value (or null) and onChange reports changes. Each option is a ComboboxOption (value, label, optional description/icon). Filtering is built in, but pass onInputChange to drive remote search, and use renderOption for custom rows, clearable for a clear button, and loading to show a fetching state.

Example

Preview
import { Combobox } from '@officina/ui';
import { useState } from 'react';

function FruitPicker() {
  const [value, setValue] = useState<string | null>(null);
  return (
    <Combobox
      value={value}
      onChange={setValue}
      clearable
      placeholder="Search fruit…"
      options={[
        { value: 'apple', label: 'Apple' },
        { value: 'banana', label: 'Banana' },
        { value: 'cherry', label: 'Cherry' },
      ]}
    />
  );
}

API

PropTypeDefaultDescription
onChange*(value: T | null) => void—Called with the chosen value (or null when cleared).
options*ComboboxOption<T>[]—Selectable options.
value*T | null—Currently selected value, or null.
clearablebooleantrueShow a clear button to reset the selection.
disabledboolean—Disables the input and prevents selection.
emptyMessagestringNo resultsMessage shown when no options match the query.
inputRefRef<HTMLInputElement>—Ref forwarded to the underlying text input.
invalidboolean—Marks the field invalid for validation styling and `aria-invalid`.
loadingboolean—Show a loading state (e.g. while fetching options).
namestring—Form field name for the underlying input.
onInputChange(q: string) => void—Called as the user types — use for async/remote filtering.
placeholderstring—Placeholder text for the input when nothing is selected.
renderOption(option: ComboboxOption<T>) => ReactNode—Custom renderer for an option row.
requiredboolean—Marks the field as required for validation styling and `aria-required`.
sizeenummdControl size.

On this page