Skip to main content
  1. Docs
  2. Components
  3. Forms

Combobox

Pick from many by typing to filter: one value, or several as pills. It can ask a server.

Import
@qeetrix/react/experimental
Status
ExperimentalSince 0.0.6
Renders
<input role="combobox">Server-rendered
Tested
WCAG 2.2 AAaxe on every pull request

01

Import

combobox.tsx
// Experimental: from the package's experimental entry, until it's stable.
import { Combobox } from "@qeetrix/react/experimental";

02

Props

And every native attribute of the element it renders.

PropTypeDefaultWhat it does
itemsComboboxItem[] | ComboboxItemGroup[]requiredAll flat, or all in groups: { value, label, description, disabled }.
value · defaultValue · onValueChangeValue | Value[]—The chosen ID, or IDs with multiple.
multiplebooleanfalseSeveral, as removable pills.
placeholderstring—Shown while empty: an example.
iconIconSource—A leading icon, 16px.
filter(item, query) => boolean | nulllabel containsHow an option matches: its label, ignoring case and accents. null shows items as given; with onSearch it's null.
allowCustombooleanfalseTyped text that matches no option is offered ("Use …") and can be the value. String values, flat items.
onSearch(query: string) => void—Search the server when typing pauses; "" at once when cleared.
searchDelaynumber300The pause before onSearch, in ms.
loadingbooleanfalseShows "Searching…", announced, and marks the list busy.
messagesPartial<…combobox>—Its words, over QeetrixProvider's.

03

Parts

Each part carries a data-slot, for tests and placement.

data-slotElementWhat it is
combobox<div>The field's box.
combobox-input<input>The input; ref lands here, and a Field labels it.
combobox-chips<div>The pills, with multiple; each combobox-chip has combobox-chip-remove.
combobox-clear<button>Clear: only while there's a value; named after the field.
combobox-popup<div>The list: combobox-list, its combobox-group and combobox-option.
combobox-status<div role="status">"Searching…" or "No matches".

04

A directory on the server

onSearch and loading; the server's results show as given, and a chosen value keeps its label when they leave it out.

owner.tsx
const [query, setQuery] = useState("");
const { data, isFetching } = useQuery({ queryKey: ["people", query], queryFn: () => searchPeople(query) });

<Field label="Owner">
  <Combobox items={data ?? []} onSearch={setQuery} loading={isFetching} />
</Field>
Next — ComboboxAccessibility