Theme

Customize appearance

Components

Combobox

Search a list of choices and select a matching value.

View component source ↗

Preview

A minimal example to get started.

Installation

Install this component and its dependencies in a project initialized with shadcn.

pnpm dlx shadcn@latest add https://ui.hyunjoon.net/r/combobox.json

Usage

This is the basic example. Use the Code tab above for the selected example. Adjust import aliases to match your project.

import {
  Combobox,
  ComboboxInput,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxList,
  ComboboxItem,
} from "@/components/ui/combobox";

export default function Example() {
  const languages = ["TypeScript", "JavaScript", "Python", "Swift"];
  return (
    <Combobox items={languages}>
      <ComboboxInput placeholder="Choose a language" aria-label="Language" />
      <ComboboxContent>
        <ComboboxEmpty>No matches.</ComboboxEmpty>
        <ComboboxList>
          {(language: string) => (
            <ComboboxItem key={language} value={language}>
              {language}
            </ComboboxItem>
          )}
        </ComboboxList>
      </ComboboxContent>
    </Combobox>
  );
}

API reference

Derived from the installed component types. Native DOM props are also supported where applicable. A dash means no explicit default is documented. Some props depend on the selected mode.

Combobox
Combobox properties
PropTypeDefaultDescription
form
string | undefined
string | undefined
—Identifies the form that owns the internal input. Useful when the combobox is rendered outside the form.
filter
((itemValue: Value, query: string, itemToString?: ((itemValue: Value) => string) | undefin…
((itemValue: Value, query: string, itemToString?: ((itemValue: Value) => string) | undefined) => boolean) | null | undefined
—Filter function used to match items vs input query.
id
string | undefined
string | undefined
—The id of the component.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
disabled
boolean | undefined
boolean | undefined
falseWhether the component should ignore user interaction.
name
string | undefined
string | undefined
—Identifies the field when a form is submitted.
modal
boolean | undefined
boolean | undefined
falseDetermines 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.
open
boolean | undefined
boolean | undefined
—Whether the popup is currently open. Use when controlled.
defaultOpen
boolean | undefined
boolean | undefined
falseWhether the popup is initially open. To render a controlled popup, use the `open` prop instead.
onOpenChangeComplete
((open: boolean) => void) | undefined
((open: boolean) => void) | undefined
—Event handler called after any animations complete when the popup is opened or closed.
inline
boolean | undefined
boolean | undefined
falseWhether the list is rendered inline without using the popup.
grid
boolean | undefined
boolean | undefined
falseWhether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows.
required
boolean | undefined
boolean | undefined
falseWhether the user must choose a value before submitting a form.
readOnly
boolean | undefined
boolean | undefined
falseWhether the user should be unable to choose a different option from the popup.
openOnInputClick
boolean | undefined
boolean | undefined
trueWhether the popup opens when clicking the input.
loopFocus
boolean | undefined
boolean | undefined
trueWhether 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>.
inputValue
string | number | readonly string[] | undefined
string | number | readonly string[] | undefined
—The input value of the combobox. Use when controlled.
defaultInputValue
string | number | readonly string[] | undefined
string | number | readonly string[] | undefined
—The uncontrolled input value when initially rendered. To render a controlled input, use the `inputValue` prop instead.
inputRef
React.Ref<HTMLInputElement> | undefined
React.Ref<HTMLInputElement> | undefined
—A ref to the hidden input element.
items
readonly any[] | readonly Group<any>[] | undefined
readonly any[] | readonly Group<any>[] | undefined
—The items to be displayed in the list. Can be either a flat array of items or an array of groups with items.
filteredItems
readonly any[] | readonly Group<any>[] | undefined
readonly any[] | readonly Group<any>[] | undefined
—Filtered 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.
virtualized
boolean | undefined
boolean | undefined
falseWhether the items are being externally virtualized.
limit
number | undefined
number | undefined
-1The maximum number of items to display in the list.
locale
Intl.LocalesArgument
Intl.LocalesArgument
—The locale to use for string comparison. Defaults to the user's runtime locale.
multiple
Multiple | undefined
Multiple | undefined
falseWhether multiple items can be selected.
autoComplete
string | undefined
string | undefined
—Provides a hint to the browser for autofill.
autoHighlight
boolean | undefined
boolean | undefined
falseWhether the first matching item is highlighted automatically while filtering.
highlightItemOnHover
boolean | undefined
boolean | undefined
trueWhether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state.
itemToStringLabel
((itemValue: Value) => string) | undefined
((itemValue: Value) => string) | undefined
—When 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) | undefined
((itemValue: Value) => string) | undefined
—When 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.
isItemEqualToValue
((itemValue: Value, value: Value) => boolean) | undefined
((itemValue: Value, value: Value) => boolean) | undefined
—Custom 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.
defaultValue
ComboboxValueType<Value, Multiple> | null | undefined
ComboboxValueType<Value, Multiple> | null | undefined
—The uncontrolled selected value of the combobox when it's initially rendered. To render a controlled combobox, use the `value` prop instead.
actionsRef
React.RefObject<AriaCombobox.Actions | null> | undefined
React.RefObject<AriaCombobox.Actions | null> | undefined
—A ref to imperative actions. - `unmount`: When specified, the combobox will not be unmounted when closed. Instead, the `unmount` function must be called to unmount the combobox manually. Useful when the combobox's animation is controlled by an external library.
onOpenChange
((open: boolean, eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void) | undef…
((open: boolean, eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void) | undefined
—Event handler called when the popup is opened or closed.
onInputValueChange
((inputValue: string, eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void) | …
((inputValue: string, eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void) | undefined
—Event handler called when the input value changes.
onItemHighlighted
((highlightedValue: Value | undefined, eventDetails: ComboboxPrimitive.Root.HighlightEvent…
((highlightedValue: Value | undefined, eventDetails: ComboboxPrimitive.Root.HighlightEventDetails) => void) | undefined
—Callback 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.
value
ComboboxValueType<Value, Multiple> | null | undefined
ComboboxValueType<Value, Multiple> | null | undefined
—The selected value of the combobox. Use when controlled.
onValueChange
((value: ComboboxValueType<Value, Multiple> | (Multiple extends true ? never : null), even…
((value: ComboboxValueType<Value, Multiple> | (Multiple extends true ? never : null), eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void) | undefined
—Event handler called when the selected value of the combobox changes.
ComboboxInput
ComboboxInput properties
PropTypeDefaultDescription
disabled
boolean | undefined
boolean | undefined
falseWhether the component should ignore user interaction.
ref
React.Ref<HTMLInputElement> | undefined
React.Ref<HTMLInputElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLInputElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLInputElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLInputElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLInputElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLInputElement, HTMLInputElement>>) => void) | un…
((event: BaseUIEvent<React.ChangeEvent<HTMLInputElement, HTMLInputElement>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLInputElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLInputElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLInputElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLInputElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
name
string | undefined
string | undefined
—Field name used in form data.
type
React.HTMLInputTypeAttribute | undefined
React.HTMLInputTypeAttribute | undefined
—The native input or button behavior.
value
string | number | readonly string[] | undefined
string | number | readonly string[] | undefined
—The current value when controlled by the application.
alt
string | undefined
string | undefined
—Accessible text alternative for the image.
src
string | undefined
string | undefined
—URL of the displayed resource.
multiple
boolean | undefined
boolean | undefined
—Allows more than one value to be selected.
max
string | number | undefined
string | number | undefined
—Maximum allowed value.
min
string | number | undefined
string | number | undefined
—Minimum allowed value.
step
string | number | undefined
string | number | undefined
—Increment between valid values.
required
boolean | undefined
boolean | undefined
—Whether the user must provide a value before form submission.
checked
boolean | undefined
boolean | undefined
—Current checked state when controlled.
maxLength
number | undefined
number | undefined
—Maximum number of input characters.
placeholder
string | undefined
string | undefined
—Hint shown when the control has no value.
className
string | ((state: ComboboxInputState) => string | undefined) | undefined
string | ((state: ComboboxInputState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxInputState> | undefined
—Allows 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
React.CSSProperties | ((state: ComboboxInputState) => React.CSSProperties | undefined) | u…
React.CSSProperties | ((state: ComboboxInputState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
showTrigger
boolean | undefined
boolean | undefined
trueDisplays a control for opening the choice list.
showClear
boolean | undefined
boolean | undefined
falseDisplays a control for clearing the selection.
ComboboxContent
ComboboxContent properties
PropTypeDefaultDescription
initialFocus
boolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boo…
boolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boolean | HTMLElement | null) | undefined
—Determines 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.
finalFocus
boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | bo…
boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null) | undefined
—Determines 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.
ref
React.Ref<HTMLDivElement> | undefined
React.Ref<HTMLDivElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
className
string | ((state: ComboboxPopupState) => string | undefined) | undefined
string | ((state: ComboboxPopupState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxPopupState> | undefined
—Allows 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
React.CSSProperties | ((state: ComboboxPopupState) => React.CSSProperties | undefined) | u…
React.CSSProperties | ((state: ComboboxPopupState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
align
Align | undefined
Align | undefined
"start"How to align the popup relative to the specified side.
side
Side | undefined
Side | undefined
"bottom"Which side of the anchor element to align the popup against. May automatically change to avoid collisions.
sideOffset
number | OffsetFunction | undefined
number | OffsetFunction | undefined
6Distance 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.
alignOffset
number | OffsetFunction | undefined
number | OffsetFunction | undefined
0Additional 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.
anchor
Element | VirtualElement | React.RefObject<Element | null> | (() => Element | VirtualEleme…
Element | VirtualElement | React.RefObject<Element | null> | (() => Element | VirtualElement | null) | null | undefined
—An element to position the popup against. By default, the popup will be positioned against the trigger.
ComboboxList
ComboboxList properties
PropTypeDefaultDescription
children
React.ReactNode | ((item: any, index: number) => React.ReactNode)
React.ReactNode | ((item: any, index: number) => React.ReactNode)
—Content rendered inside this component.
className
string | ((state: ComboboxListState) => string | undefined) | undefined
string | ((state: ComboboxListState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
style
React.CSSProperties | ((state: ComboboxListState) => React.CSSProperties | undefined) | un…
React.CSSProperties | ((state: ComboboxListState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
ref
React.Ref<HTMLDivElement> | undefined
React.Ref<HTMLDivElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxListState> | undefined
—Allows 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.
ComboboxItem
ComboboxItem properties
PropTypeDefaultDescription
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
—An 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.
index
number | undefined
number | undefined
—The index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM.
value
any
any
nullA unique value that identifies this item.
disabled
boolean | undefined
boolean | undefined
falseWhether the component should ignore user interaction.
nativeButton
boolean | undefined
boolean | undefined
falseWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button.
className
string | ((state: ComboboxItemState) => string | undefined) | undefined
string | ((state: ComboboxItemState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
style
React.CSSProperties | ((state: ComboboxItemState) => React.CSSProperties | undefined) | un…
React.CSSProperties | ((state: ComboboxItemState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
ref
React.Ref<HTMLDivElement> | undefined
React.Ref<HTMLDivElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxItemState> | undefined
—Allows 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.
ComboboxGroup
ComboboxGroup properties
PropTypeDefaultDescription
items
readonly any[] | undefined
readonly any[] | undefined
—Items to be rendered within this group. When provided, child `Collection` components will use these items.
ref
React.Ref<HTMLDivElement> | undefined
React.Ref<HTMLDivElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
className
string | ((state: ComboboxGroupState) => string | undefined) | undefined
string | ((state: ComboboxGroupState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxGroupState> | undefined
—Allows 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
React.CSSProperties | ((state: ComboboxGroupState) => React.CSSProperties | undefined) | u…
React.CSSProperties | ((state: ComboboxGroupState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
ComboboxLabel
ComboboxLabel properties
PropTypeDefaultDescription
ref
React.Ref<HTMLDivElement> | undefined
React.Ref<HTMLDivElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
className
string | ((state: ComboboxGroupLabelState) => string | undefined) | undefined
string | ((state: ComboboxGroupLabelState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxGroupLabelState> | undefined
—Allows 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
React.CSSProperties | ((state: ComboboxGroupLabelState) => React.CSSProperties | undefined…
React.CSSProperties | ((state: ComboboxGroupLabelState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
ComboboxCollection
ComboboxCollection properties
PropTypeDefaultDescription
childrenRequired
(item: any, index: number) => React.ReactNode
(item: any, index: number) => React.ReactNode
—Content rendered inside this component.
ComboboxEmpty
ComboboxEmpty properties
PropTypeDefaultDescription
ref
React.Ref<HTMLDivElement> | undefined
React.Ref<HTMLDivElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
className
string | ((state: ComboboxEmptyState) => string | undefined) | undefined
string | ((state: ComboboxEmptyState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxEmptyState> | undefined
—Allows 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
React.CSSProperties | ((state: ComboboxEmptyState) => React.CSSProperties | undefined) | u…
React.CSSProperties | ((state: ComboboxEmptyState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
ComboboxSeparator
ComboboxSeparator properties
PropTypeDefaultDescription
orientation
Orientation | undefined
Orientation | undefined
'horizontal'The orientation of the separator.
ref
React.Ref<HTMLDivElement> | undefined
React.Ref<HTMLDivElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
className
string | ((state: SeparatorState) => string | undefined) | undefined
string | ((state: SeparatorState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SeparatorState> | undefined
—Allows 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
React.CSSProperties | ((state: SeparatorState) => React.CSSProperties | undefined) | undef…
React.CSSProperties | ((state: SeparatorState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
ComboboxChips
ComboboxChips properties
PropTypeDefaultDescription
className
string | ((state: ComboboxChipsState) => string | undefined) | undefined
string | ((state: ComboboxChipsState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
style
React.CSSProperties | ((state: ComboboxChipsState) => React.CSSProperties | undefined) | u…
React.CSSProperties | ((state: ComboboxChipsState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxChipsState> | undefined
—Allows 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.
ref
React.Ref<HTMLDivElement> | undefined
React.Ref<HTMLDivElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
ComboboxChip
ComboboxChip properties
PropTypeDefaultDescription
ref
React.Ref<HTMLDivElement> | undefined
React.Ref<HTMLDivElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
className
string | ((state: ComboboxChipState) => string | undefined) | undefined
string | ((state: ComboboxChipState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxChipState> | undefined
—Allows 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
React.CSSProperties | ((state: ComboboxChipState) => React.CSSProperties | undefined) | un…
React.CSSProperties | ((state: ComboboxChipState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
showRemove
boolean | undefined
boolean | undefined
trueConfigures show remove; see the accepted type.
ComboboxChipsInput
ComboboxChipsInput properties
PropTypeDefaultDescription
disabled
boolean | undefined
boolean | undefined
falseWhether the component should ignore user interaction.
ref
React.Ref<HTMLInputElement> | undefined
React.Ref<HTMLInputElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLInputElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLInputElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLInputElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLInputElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLInputElement, HTMLInputElement>>) => void) | un…
((event: BaseUIEvent<React.ChangeEvent<HTMLInputElement, HTMLInputElement>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLInputElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLInputElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLInputElement, MouseEvent>>) => void) | undefined
((event: BaseUIEvent<React.MouseEvent<HTMLInputElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
name
string | undefined
string | undefined
—Field name used in form data.
type
React.HTMLInputTypeAttribute | undefined
React.HTMLInputTypeAttribute | undefined
—The native input or button behavior.
value
string | number | readonly string[] | undefined
string | number | readonly string[] | undefined
—The current value when controlled by the application.
alt
string | undefined
string | undefined
—Accessible text alternative for the image.
src
string | undefined
string | undefined
—URL of the displayed resource.
multiple
boolean | undefined
boolean | undefined
—Allows more than one value to be selected.
max
string | number | undefined
string | number | undefined
—Maximum allowed value.
min
string | number | undefined
string | number | undefined
—Minimum allowed value.
step
string | number | undefined
string | number | undefined
—Increment between valid values.
required
boolean | undefined
boolean | undefined
—Whether the user must provide a value before form submission.
checked
boolean | undefined
boolean | undefined
—Current checked state when controlled.
maxLength
number | undefined
number | undefined
—Maximum number of input characters.
placeholder
string | undefined
string | undefined
—Hint shown when the control has no value.
className
string | ((state: ComboboxInputState) => string | undefined) | undefined
string | ((state: ComboboxInputState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxInputState> | undefined
—Allows 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
React.CSSProperties | ((state: ComboboxInputState) => React.CSSProperties | undefined) | u…
React.CSSProperties | ((state: ComboboxInputState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
ComboboxTrigger
ComboboxTrigger properties
PropTypeDefaultDescription
disabled
boolean | undefined
boolean | undefined
falseWhether the component should ignore user interaction.
nativeButton
boolean | undefined
boolean | undefined
trueWhether 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>`).
ref
React.Ref<HTMLButtonElement> | undefined
React.Ref<HTMLButtonElement> | undefined
—Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
id
string | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
onFocus
((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined
—Called when the control receives focus.
onBlur
((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined
—Called when the control loses focus.
onChange
((event: BaseUIEvent<React.ChangeEvent<HTMLButtonElement, Element>>) => void) | undefined
((event: BaseUIEvent<React.ChangeEvent<HTMLButtonElement, Element>>) => void) | undefined
—Called when the underlying form control changes; inspect the event for its value.
onKeyDown
((event: BaseUIEvent<React.KeyboardEvent<HTMLButtonElement>>) => void) | undefined
((event: BaseUIEvent<React.KeyboardEvent<HTMLButtonElement>>) => void) | undefined
—Called when a key is pressed while this element is focused.
onClick
((event: BaseUIEvent<React.MouseEvent<HTMLButtonElement, MouseEvent>>) => void) | undefine…
((event: BaseUIEvent<React.MouseEvent<HTMLButtonElement, MouseEvent>>) => void) | undefined
—Called when the element is activated.
name
string | undefined
string | undefined
—Field name used in form data.
type
"button" | "submit" | "reset" | undefined
"button" | "submit" | "reset" | undefined
—The native input or button behavior.
value
string | number | readonly string[] | undefined
string | number | readonly string[] | undefined
—The current value when controlled by the application.
className
string | ((state: ComboboxTriggerState) => string | undefined) | undefined
string | ((state: ComboboxTriggerState) => string | undefined) | undefined
—CSS class applied to the element, or a function that returns a class based on the component's state.
render
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…
React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxTriggerState> | undefined
—Allows 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
React.CSSProperties | ((state: ComboboxTriggerState) => React.CSSProperties | undefined) |…
React.CSSProperties | ((state: ComboboxTriggerState) => React.CSSProperties | undefined) | undefined
—Style applied to the element, or a function that returns a style object based on the component's state.
ComboboxValue
ComboboxValue properties
PropTypeDefaultDescription
children
React.ReactNode | ((selectedValue: any) => React.ReactNode)
React.ReactNode | ((selectedValue: any) => React.ReactNode)
—Content rendered inside this component.
placeholder
React.ReactNode
React.ReactNode
—The 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`.

Usage notes

Pass items to the root and render options in ComboboxList. Include an empty state for searches without results.