An input that allows users to filter and select a value from a list of suggestions.
Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
Combobox ├── ComboboxLabel (optional) ├── ComboboxControl | ComboboxTagsControl │ ├── ComboboxInput | ComboboxTagsInput │ ├── ComboboxTag (multiple values) │ ├── ComboboxClearTrigger (optional) │ └── ComboboxTrigger └── ComboboxContent ├── ComboboxEmpty (optional) ├── ComboboxList │ ├── ComboboxItemGroup │ │ ├── ComboboxItemGroupLabel │ │ └── ComboboxItem │ │ ├── ComboboxItemText │ │ └── ComboboxItemIndicator │ └── ComboboxSeparator (optional)
Examples
Button Trigger
Loading...
Default
Loading...
Groups
Loading...
Multiple Selection
Loading...
Single Selection
Loading...
Sizes
Loading...
With Description
Loading...
API Reference
Combobox
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | undefined | — | Unique identifier used to connect the component parts. |
open | boolean | undefined | — | Whether the component is open when controlled. |
defaultOpen | boolean | undefined | — | Initial open state when uncontrolled. |
ids | ElementIds | undefined | — | Overrides generated identifiers for individual parts. |
inputValue | string | undefined | — | Configures input value. |
defaultInputValue | string | undefined | — | Configures default input value. |
name | string | undefined | — | Name used when submitting the value with a form. |
form | string | undefined | — | Associates the control with a form by ID. |
disabled | boolean | undefined | false | Disables interaction with the component. |
readOnly | boolean | undefined | false | Prevents changes while preserving focus and navigation. |
invalid | boolean | undefined | — | Marks the associated form control as invalid. |
required | boolean | undefined | false | Marks the associated form control as required. |
placeholder | string | undefined | — | Configures placeholder. |
defaultHighlightedValue | string | null | undefined | — | Configures default highlighted value. |
highlightedValue | string | null | undefined | — | Configures highlighted value. |
value | string[] | undefined | — | Current value when the component is controlled. |
defaultValue | string[] | undefined | — | Initial value when the component is uncontrolled. |
inputBehavior | "autohighlight" | "autocomplete" | "none" | undefined | — | Configures input behavior. |
selectionBehavior | "clear" | "replace" | "preserve" | undefined | — | Configures selection behavior. |
autoFocus | boolean | undefined | — | Configures auto focus. |
openOnClick | boolean | undefined | — | Configures open on click. |
openOnChange | boolean | ((details: InputValueChangeDetails) => boolean) | undefined | — | Configures open on change. |
allowCustomValue | boolean | undefined | — | Configures allow custom value. |
alwaysSubmitOnEnter | boolean | undefined | — | Configures always submit on enter. |
loopFocus | boolean | undefined | — | Configures loop focus. |
positioning | PositioningOptions | undefined | — | Configures floating-element placement and collision handling. |
onInputValueChange | ((details: InputValueChangeDetails) => void) | undefined | — | Runs when input value changes. |
onValueChange | ((details: ValueChangeDetails<T>) => void) | undefined | — | Runs when value changes. |
onHighlightChange | ((details: HighlightChangeDetails<T>) => void) | undefined | — | Runs when highlight changes. |
onSelect | ((details: SelectionDetails) => void) | undefined | — | Runs when select changes. |
onOpenChange | ((details: OpenChangeDetails) => void) | undefined | — | Runs when open changes. |
translations | IntlTranslations | undefined | — | Configures translations. |
collection | ListCollection<T> | undefined | — | Collection that supplies the component items. |
multiple | boolean | undefined | false | Allows more than one value to be selected or expanded. |
closeOnSelect | boolean | undefined | true | Configures close on select. |
openOnKeyPress | boolean | undefined | — | Configures open on key press. |
scrollToIndexFn | ((details: ScrollToIndexDetails) => void) | undefined | — | Configures scroll to index fn. |
composite | boolean | undefined | — | Configures composite. |
disableLayer | boolean | undefined | — | Configures disable layer. |
navigate | ((details: NavigateDetails) => void) | null | undefined | — | Configures navigate. |
Context, Hooks, and Types
| Export | API |
|---|---|
ComboboxContext | Render-prop component that exposes component state and actions. |
ComboboxRootProvider | Provides an externally created API to the component tree. |
useCombobox | Creates or accesses the component API. |
useComboboxContext | Returns the nearest component API. |
useListCollection | Creates or accesses the component API. |
ComboboxInputValueChangeDetails | Type for the details object passed to the matching change callback. |
ComboboxValueChangeDetails | Type for the details object passed to the matching change callback. |
useFilter | Creates or accesses the component API. |
Utilities and Supporting Types
| Export | API |
|---|---|
createListCollection | Creates the typed collection consumed by the component. |
Angular
React
Solid
Svelte
Vue