ComboBox

Molecule

Searchable autocomplete single-select with keyboard navigation, described options, and a clearable button.

Controlled selection

Preview

Search or pick from the list.

Selected: nextjs

Code
function Demo() {
  const [value, setValue] = useState('nextjs');
  return (
    <ComboBox
      id="framework"
      label="Framework"
      options={COMBO_OPTIONS}
      value={value}
      onChange={setValue}
    />
  );
}

Async search

Preview

Selected: none

Code
<ComboBox id="search" label="Async search" options={COMBO_OPTIONS} onSearch={search} value={value} onChange={setValue} />

Debounced async suggestions

Preview

Debounced 300ms, AbortController cancels in-flight, 5-min cache.

Selected: none

Code
async function suggest(query, signal) {
  const res = await fetch('/api/suggest?q=' + encodeURIComponent(query), { signal });
  return res.json();
}

<ComboBox
  id="cb-async-debounced"
  label="Debounced suggestions"
  options={[]}
  value={value}
  onChange={setValue}
  onSearch={suggest}      // signature: (q, signal) => Promise<Option[]>
  debounceMs={300}        // useAsync debounces & cancels in-flight
  placeholder="Type to search…"
/>
Sourcemodules/ui/ComboBox/index.tsx