Combobox
An editable input paired with a filtered list of selectable options.
ComboboxView sourceExample
The preview is interactive. The code below it is the docs demo source; demo-only layout classes can be omitted in application code.
import { Cell, For } from "retend";
import { Combobox, Field } from "innate-ui";
import classes from "../docs.module.css";
import { Icon } from "@/docs/icons/Icon";
type IssueType = "" | "bug" | "documentation" | "enhancement" | "help-wanted" | "good-first-issue";
const options = [
["bug", "bug"],
["documentation", "documentation"],
["enhancement", "enhancement"],
["help-wanted", "help wanted"],
["good-first-issue", "good first issue"],
] as const;
export function ComboboxDemo() {
const selected = Cell.source<IssueType>("");
return (
<Field id="issue-field" class={classes.fullControl}>
<Field.Label>Issue type</Field.Label>
<Combobox
id="issue-combobox"
value={selected}
onChange={(value) => selected.set(value)}
placeholder="Select an issue..."
>
<Combobox.CaretIcon>
<Icon name="chevronDown" data-slot-icon="combobox-caret" />
</Combobox.CaretIcon>
<Combobox.CheckIcon>
<Icon name="check" data-slot-icon="combobox-check" />
</Combobox.CheckIcon>
{For(options, ([value, label]) => (
<Combobox.Option value={value} textValue={label}>
{label}
</Combobox.Option>
))}
</Combobox>
</Field>
);
}API reference
This table is generated from Innate UI's exported TypeScript declarations and JSDoc. Native element attributes inherited by a prop type are not repeated here.
ComboboxProps
| Prop | Type | Default |
|---|---|---|
idrequiredStable id used to connect the input and listbox. | string | — |
valuerequiredSelected option value. | JSX.ValueOrCell<Value> | — |
childrenrequired`Combobox.Option` children. | JSX.Children | — |
queryCurrent search query. | JSX.ValueOrCell<string> | — |
openWhether the options popover is open. | JSX.ValueOrCell<boolean> | — |
placeholderInput placeholder. | JSX.ValueOrCell<string> | "Search options" |
emptyTextMessage shown when no options match. | JSX.ValueOrCell<string> | "No options found" |
disabledWhether the combobox is disabled. | JSX.ValueOrCell<boolean> | false |
invalidWhether the combobox is in an invalid state. | JSX.ValueOrCell<boolean> | false |
ariaDescribedByIds of elements that describe the combobox. | JSX.ValueOrCell<string | undefined> | — |
showCaretWhether to show the caret icon. | JSX.ValueOrCell<boolean> | true |
hideWhenEmptyHides the popup when filtering produces no options. | JSX.ValueOrCell<boolean> | false |
filterCustom option filtering function. | ComboboxFilter<Value> | — |
onChangeCalled when an option is selected. | (value: Value) => void | — |
onQueryChangeCalled when the search query changes. | (query: string) => void | — |
onOpenChangeCalled when the popover requests an open-state change. | (open: boolean, reason?: PopoverCloseReason) => void | — |