Combobox
Combobox combines a text input with a filterable listbox. Use when the list is long enough that free-text filtering improves efficiency. For short lists, use Select.
Code
<Combobox items={[ { value: "corn-seed", label: "Corn seed" }, { value: "soybean-seed", label: "Soybean seed" }, { value: "starter-fertilizer", label: "Starter fertilizer" }, { value: "crop-protection", label: "Crop protection" }, { value: "nitrogen", label: "Nitrogen" }, { value: "potash", label: "Potash" }, ]}> <ComboboxInput placeholder="Select product..." showClear />
<ComboboxContent> <ComboboxEmpty>No products found.</ComboboxEmpty>
<ComboboxList> {(product) => ( <ComboboxItem key={product.value} value={product}> {product.label} </ComboboxItem> )} </ComboboxList> </ComboboxContent></Combobox>Combobox
Section titled “Combobox”| Name | Type/Description |
|---|---|
actionsRef | RefObject<Actions | null> | undefinedA ref to imperative actions. - `unmount`: Manually unmounts the combobox. Call this after any externally controlled closing animation finishes. |
autoComplete | string | undefinedProvides a hint to the browser for autofill. @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/autocomplete |
autoHighlight = false | boolean | undefinedWhether the first matching item is highlighted automatically while filtering. |
defaultInputValue | string | number | readonly string[] | undefinedThe uncontrolled input value when initially rendered. To render a controlled input, use the `inputValue` prop instead. |
defaultOpen = false | boolean | undefinedWhether the popup is initially open. To render a controlled popup, use the `open` prop instead. |
defaultValue | ComboboxValueType<Value, Multiple> | null | undefinedThe uncontrolled selected value of the combobox when it's initially rendered. To render a controlled combobox, use the `value` prop instead. |
disabled = false | boolean | undefinedWhether the component should ignore user interaction. |
filter | ((itemValue: Value, query: string, itemToString?: ((itemValue: Value) => string) | undefined) => boolean) | null | undefinedFilter function used to match items vs input query. |
filteredItems | readonly any[] | readonly Group<any>[] | undefinedFiltered items to display in the list. When provided, the list will use these items instead of filtering the `items` prop internally. Use when you want to control filtering logic externally with the `useFilter()` hook. |
form | string | undefinedIdentifies the form that owns the internal input. Useful when the combobox is rendered outside the form. |
grid = false | boolean | undefinedWhether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows. |
highlightItemOnHover = true | boolean | undefinedWhether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state. |
id | string | undefinedThe id of the component. |
inline = false | boolean | undefinedWhether the list is rendered inline without using the component's own popup. Specify `open` unconditionally in conjunction with this prop so the list is considered visible: `<Combobox.Root inline open>` In a `Combobox.Root` > `Dialog.Root` composition, bind the Combobox's `open` and `onOpenChange` props to the `Dialog`'s `open` and `onOpenChange` state instead so the component resets its transient state (filter query, highlighted item, and input value) when the dialog closes. |
inputRef | Ref<HTMLInputElement> | undefinedA ref to the hidden input element. |
inputValue | string | number | readonly string[] | undefinedThe input value of the combobox. Use when controlled. |
isItemEqualToValue | ((itemValue: Value, value: Value) => boolean) | undefinedCustom comparison logic used to determine if a combobox item value matches the current selected value. Useful when item values are objects without matching referentially. Defaults to `Object.is` comparison. |
items | readonly any[] | readonly Group<any>[] | undefinedThe items to be displayed in the list. Can be either a flat array of items or an array of groups with items. |
itemToStringLabel | ((itemValue: Value) => string) | undefinedWhen the item values are objects (`<Combobox.Item value={object}>`), this function converts the object value to a string representation for display in the input. If the shape of the object is `{ value, label }`, the label will be used automatically without needing to specify this prop. |
itemToStringValue | ((itemValue: Value) => string) | undefinedWhen the item values are objects (`<Combobox.Item value={object}>`), this function converts the object value to a string representation for form submission. If the shape of the object is `{ value, label }`, the value will be used automatically without needing to specify this prop. |
limit = -1 | number | undefinedThe maximum number of items to display in the list. |
locale | LocalesArgumentThe locale to use for string comparison. Defaults to the user's runtime locale. |
loopFocus = true | boolean | undefinedWhether to loop keyboard focus back to the input when the end of the list is reached while using the arrow keys. The first item can then be reached by pressing <kbd>ArrowDown</kbd> again from the input, or the last item can be reached by pressing <kbd>ArrowUp</kbd> from the input. The input is always included in the focus loop per [ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/). When disabled, focus does not move when on the last element and the user presses <kbd>ArrowDown</kbd>, or when on the first element and the user presses <kbd>ArrowUp</kbd>. |
modal = false | boolean | undefinedDetermines if the popup enters a modal state when open. - `true`: user interaction is limited to the popup: document page scroll is locked and pointer interactions on outside elements are disabled. - `false`: user interaction with the rest of the document is allowed. |
multiple = false | boolean | undefinedWhether multiple items can be selected. |
name | string | undefinedIdentifies the field when a form is submitted. |
onInputValueChange | ((inputValue: string, eventDetails: ChangeEventDetails) => void) | undefinedEvent handler called when the input value changes. |
onItemHighlighted | ((highlightedValue: Value | undefined, eventDetails: HighlightEventDetails) => void) | undefinedCallback fired when an item is highlighted or unhighlighted. Receives the highlighted item value (or `undefined` if no item is highlighted) and event details with a `reason` property describing why the highlight changed. The `reason` can be: - `'keyboard'`: the highlight changed due to keyboard navigation. - `'pointer'`: the highlight changed due to pointer hovering. - `'none'`: the highlight changed programmatically. |
onOpenChange | ((open: boolean, eventDetails: ChangeEventDetails) => void) | undefinedEvent handler called when the popup is opened or closed. |
onOpenChangeComplete | ((open: boolean) => void) | undefinedEvent handler called after any animations complete when the popup is opened or closed. |
onValueChange | ((value: ComboboxValueType<Value, Multiple> | (Multiple extends true ? never : null), eventDetails: ChangeEventDetails) => void) | undefinedEvent handler called when the selected value of the combobox changes. |
open | boolean | undefinedWhether the popup is currently open. Use when controlled. |
openOnInputClick = true | boolean | undefinedWhether the popup opens when clicking the input. |
readOnly = false | boolean | undefinedWhether the user should be unable to choose a different option from the popup. |
required = false | boolean | undefinedWhether the user must choose a value before submitting a form. |
value | ComboboxValueType<Value, Multiple> | null | undefinedThe selected value of the combobox. Use when controlled. |
virtualized = false | boolean | undefinedWhether the items are being externally virtualized. |
ComboboxChip
Section titled “ComboboxChip”| Name | Type/Description |
|---|---|
className | string | ((state: ComboboxChipState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
ref | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxChipState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
showRemove = true | boolean | undefined |
style | CSSProperties | ((state: ComboboxChipState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxChips
Section titled “ComboboxChips”| Name | Type/Description |
|---|---|
className | string | ((state: ComboboxChipsState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
ref | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxChipsState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties | ((state: ComboboxChipsState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxChipsInput
Section titled “ComboboxChipsInput”| Name | Type/Description |
|---|---|
className | string | ((state: ComboboxInputState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
disabled = false | boolean | undefinedWhether the component should ignore user interaction. |
ref | ((instance: HTMLInputElement | null) => void) | RefObject<HTMLInputElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxInputState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties | ((state: ComboboxInputState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxCollection
Section titled “ComboboxCollection”No documented props
ComboboxContent
Section titled “ComboboxContent”| Name | Type/Description |
|---|---|
align = "start" | Align | undefinedHow to align the popup relative to the specified side. |
alignOffset = 0 | number | OffsetFunction | undefinedAdditional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object parameter with the following properties: - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`. - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`. - `data.side`: which side of the anchor element the positioner is aligned against. - `data.align`: how the positioner is aligned relative to the specified side. @example ```jsx <Positioner alignOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.width : anchor.height; }} /> ``` |
anchor | Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | null | undefinedAn element to position the popup against. By default, the popup will be positioned against the trigger. |
className | string | ((state: ComboboxPopupState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
finalFocus | boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null) | undefinedDetermines the element to focus when the popup is closed. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (trigger or previously focused element). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing. |
initialFocus | boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | void | HTMLElement | null) | undefinedDetermines the element to focus when the popup is opened. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (first tabbable element or popup). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing. |
ref | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxPopupState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
side = "bottom" | Side | undefinedWhich side of the anchor element to align the popup against. May automatically change to avoid collisions. |
sideOffset = 6 | number | OffsetFunction | undefinedDistance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object parameter with the following properties: - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`. - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`. - `data.side`: which side of the anchor element the positioner is aligned against. - `data.align`: how the positioner is aligned relative to the specified side. @example ```jsx <Positioner sideOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.height : anchor.width; }} /> ``` |
style | CSSProperties | ((state: ComboboxPopupState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxEmpty
Section titled “ComboboxEmpty”| Name | Type/Description |
|---|---|
className | string | ((state: ComboboxEmptyState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
ref | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxEmptyState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties | ((state: ComboboxEmptyState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxGroup
Section titled “ComboboxGroup”| Name | Type/Description |
|---|---|
className | string | ((state: ComboboxGroupState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
items | readonly any[] | undefinedItems to be rendered within this group. When provided, child `Collection` components will use these items. |
ref | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxGroupState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties | ((state: ComboboxGroupState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxInput
Section titled “ComboboxInput”| Name | Type/Description |
|---|---|
className | string | ((state: ComboboxInputState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
disabled = false | boolean | undefinedWhether the component should ignore user interaction. |
ref | ((instance: HTMLInputElement | null) => void) | RefObject<HTMLInputElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxInputState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
showClear = false | boolean | undefined |
showTrigger = true | boolean | undefined |
style | CSSProperties | ((state: ComboboxInputState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxItem
Section titled “ComboboxItem”Pass the full item object as value, not just the string id
— Base UI needs the full object to extract the label.
| Name | Type/Description |
|---|---|
className | string | ((state: ComboboxItemState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
disabled = false | boolean | undefinedWhether the component should ignore user interaction. |
index | number | undefinedThe index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM. |
nativeButton = true | boolean | undefinedWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`). |
onClick | ((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefinedAn optional click handler for the item when selected. It fires when clicking the item with the pointer, as well as when pressing `Enter` with the keyboard if the item is highlighted when the `Input` or `List` element has focus. |
ref | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxItemState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties | ((state: ComboboxItemState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
value = "null" | anyA unique value that identifies this item. |
ComboboxLabel
Section titled “ComboboxLabel”| Name | Type/Description |
|---|---|
className | string | ((state: ComboboxGroupLabelState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
ref | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxGroupLabelState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties | ((state: ComboboxGroupLabelState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxList
Section titled “ComboboxList”| Name | Type/Description |
|---|---|
className | string | ((state: ComboboxListState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
ref | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxListState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties | ((state: ComboboxListState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxSeparator
Section titled “ComboboxSeparator”| Name | Type/Description |
|---|---|
className | string | ((state: SeparatorState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
orientation = "'horizontal'" | Orientation | undefinedThe orientation of the separator. |
ref | ((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SeparatorState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties | ((state: SeparatorState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxTrigger
Section titled “ComboboxTrigger”| Name | Type/Description |
|---|---|
className | string | ((state: ComboboxTriggerState) => string | undefined) | undefinedCSS class applied to the element, or a function that returns a class based on the component's state. |
disabled = false | boolean | undefinedWhether the component should ignore user interaction. |
nativeButton = true | boolean | undefinedWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`). |
render | ReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxTriggerState> | undefinedAllows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties | ((state: ComboboxTriggerState) => CSSProperties | undefined) | undefinedStyle applied to the element, or a function that returns a style object based on the component's state. |
ComboboxValue
Section titled “ComboboxValue”| Name | Type/Description |
|---|---|
placeholder | ReactNodeThe placeholder value to display when no value is selected. This is overridden by `children` if specified, or by a null item's label in `items`. |