Skip to content

shadcn.io is an independent project built on shadcn/ui

Components

Free

Combobox for React

A text field that filters a long list as people type, with chips for several picks, grouped options and an empty state. For React apps using Base UI.

On this page9 sections

A combobox is a text field with a list under it: type a few letters, the list narrows to the options that match, and the arrow keys or the pointer pick one. Reach for it when the list is too long to scan, such as countries, time zones or the people on a team.

For a handful of fixed options, a Select is quicker. When any typed text is a valid answer and the list only suggests, use an Autocomplete.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Combobox anatomy: control, input, trigger, content, item, item indicator

Usage

import {
  Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem,
  ComboboxList,
} from "@/components/ui/combobox";
const frameworks = [
  "Next.js",
  "SvelteKit",
  "Nuxt.js",
  "Remix",
  "Astro",
] as const;

const ComboboxDemo = () => (
  <Combobox items={frameworks}>
    <ComboboxInput aria-label="Framework" placeholder="Select a framework" />
    <ComboboxContent>
      <ComboboxEmpty>No items found.</ComboboxEmpty>
      <ComboboxList>
        {(item) => (
          <ComboboxItem key={item} value={item}>
            {item}
          </ComboboxItem>
        )}
      </ComboboxList>
    </ComboboxContent>
  </Combobox>
);

Accessibility

The input has role="combobox" and reports aria-expanded, and focus stays in it while the arrow keys move a highlight through the list, which it reports with aria-activedescendant. Naming the field is up to you: give ComboboxInput an aria-label, as most demos here do, or an id for a label's htmlFor. ComboboxLabel here is a group's heading, not the field's label.

Arrow Down
When the list is closed, opens it. When it's open, moves the highlight to the next option.
Arrow Up
When the list is closed, opens it. When it's open, moves the highlight to the previous option.
Enter
Selects the highlighted option. With nothing highlighted, closes the list and lets the form submit.
Escape
Closes the list. When the list is already closed, clears the text and the selection.
Home
Moves the text cursor to the start of the input.
End
Moves the text cursor to the end of the input.
Backspace
In a multiple combobox, removes the last chip when the input is empty, or the chip that has focus.
Arrow Left
In a multiple combobox, with the cursor at the start of the input, moves focus to the last chip, and from there between chips. In a right-to-left layout, ArrowRight does this.

Demos

Basic

Five front-end frameworks in a text field. Type "nu" and only Nuxt.js is left. Type a word that matches none of them and ComboboxEmpty says "No items found." This is the same setup as the preview at the top of the page: one choice from a flat list, and the starting point for every demo below.

Preview width

Multiple

Next.js starts as a chip, every framework you pick joins it, and the text field sits at the end of the row. Each chip has its own remove button, and Backspace in the empty field removes the last one. The list opens under the whole row because useComboboxAnchor hands it to ComboboxContent as the anchor. Use it for tags or filters, where several answers are normal.

Preview width

Clear

The field starts on Next.js, and showClear on ComboboxInput adds a button that empties it, shown in place of the chevron. Offer it when an empty answer is allowed or people often change their mind, so they don't have to select the text and delete it. Leave it off a required field, where empty is never a valid answer.

Preview width

Groups

Eighteen time zones under three headings, Americas, Europe and Asia/Pacific, with a separator between the groups and "No timezones found." when nothing matches. Each heading is a ComboboxLabel at the top of its ComboboxGroup. Group the options when people know the region before the city.

Preview width

Custom

Nineteen countries, each row an Item inside ComboboxItem with the name over the continent and the country code. Typing still matches on the name alone, so the second line is there to read, not to search. Use a richer row when the name isn't enough to choose, and keep it to two lines so the list doesn't turn into a table.

Preview width

Invalid

The framework field in its error state. aria-invalid on ComboboxInput turns the border red and tells screen readers the value is wrong. Nothing here says why, so show it after a submit fails, with a sentence under the field in a Field. An empty optional field isn't invalid, so don't paint it red on first view.

Preview width

Disabled

The framework field, shown but switched off. disabled on ComboboxInput disables the text field and its chevron, so nothing can be typed and the list can't open. Use it when the value is fixed by the plan or the person's role, and showing it still matters. When there's nothing to choose at all, plain text reads better than a control that looks broken.

Preview width

Auto highlight

autoHighlight on Combobox highlights the first match as soon as you type, so Enter picks it with no arrow key first. Turn it on when the top match is nearly always the one people want, and leave it off when the first hit is often wrong, since Enter would take it.

Preview width

A button that reads "Select country" opens a popup with its own search field above 19 countries, because ComboboxInput sits inside ComboboxContent with showTrigger turned off. Closed, the control looks like a Select and takes less room than a text field. The prompt is also the first row of the list, so picking it resets the choice.

Preview width

Input group

A globe icon sits at the start of the field, an InputGroupAddon passed to ComboboxInput, over the grouped time zones. The popup is widened and shifted 28 pixels toward the start, which lines it up with the field's outer edge, because Base UI anchors it to the text input that starts after the icon. Add an icon when it says what the field is for faster than the placeholder.

Preview width

RTL

Arabic categories in a multiple combobox, starting with one chip, with dir set to rtl on the Field and on ComboboxContent, which renders in a portal outside it. The chips, the text field and the list all run right to left, and the empty message is in Arabic too.

Preview width

FAQ

Should I use a Combobox or a Select?

Use a Combobox when the list is long enough that people would rather type than scroll: countries, time zones, the people on a team. Typing narrows the list, so a hundred options feel like five.

Use a Select for a short, fixed set such as a status or a sort order, where a text field would be one more thing to fill in. If any typed text is a valid answer and the list only suggests, that's an Autocomplete.

How do I filter Combobox options as the user types?

Base UI filters for you. Pass the options as items on Combobox and render them from the function child of ComboboxList, and typing narrows them with a locale-aware match on each item's label. Pass your own filter to match differently, or set it to null when a server has already filtered the results.

How do I load Combobox options from an API as someone types?

Control the text with inputValue and onInputValueChange, fetch from the change handler, and pass the results as items. Set filter to null so Base UI shows the server's results as they are instead of filtering them a second time.

Keep each response with the query that asked for it, and drop one that arrives after a newer query, or a slow request can replace a fresh list with stale results.

How do I select multiple values in a Combobox?

Add multiple to Combobox, and the value becomes an array. Show the picks inside ComboboxChips, with a ComboboxChip per value and a ComboboxChipsInput at the end, as the Multiple demo does. Pass the ref from useComboboxAnchor to both ComboboxChips and ComboboxContent so the list opens under the whole row.

How do I control the Combobox value in React?

Hold the selection in state, pass it as value and update it in onValueChange, which receives the new value first and event details second. The value is the item itself, a string or an object, null once cleared, and an array with multiple. The typed text is separate, and inputValue with onInputValueChange controls it.

Can users type a value that isn't in the Combobox list?

Not with this component. Base UI keeps a combobox's value to one of its items, and text that matches nothing never becomes the value.

When free text is the normal answer and the list only suggests, an Autocomplete fits better, because its value is the text itself.

How do I show a message when no Combobox options match?

Put a ComboboxEmpty inside ComboboxContent with the text, such as "No items found.", as the demos do. Base UI renders that text only when the filter leaves nothing, so it can stay in the markup all the time.

Say what to do next where you can, such as checking the spelling or creating the missing item.

How do I submit a Combobox with a form?

Set name on Combobox, and Base UI renders a hidden input with the chosen item's value, or one per value with multiple. For object items, itemToStringValue decides what's sent, and an object shaped like { value, label } sends its value without it. Add required to block an empty submission.

With a form library, connect the field's value to the controlled value and its change handler, and wrap the combobox in a Field for the label and the error.

API Reference

Combobox

PropType
inputValue?React.ComponentProps<"input">["value"]

The input value of the combobox. Use when controlled.

Type
React.ComponentProps<"input">["value"]
defaultInputValue?React.ComponentProps<"input">["defaultValue"]

The uncontrolled input value when initially rendered. To render a controlled input, use the inputValue prop instead.

Type
React.ComponentProps<"input">["defaultValue"]
Default
""
onInputValueChange?(inputValue: string, eventDetails: ComboboxRoot.ChangeEventDetails) → void

Event handler called when the input value changes.

Type
(inputValue: string, eventDetails: ComboboxRoot.ChangeEventDetails) → void
Parameters

inputValue – string

eventDetails – ComboboxRoot.ChangeEventDetails

Returns
void
open?boolean

Whether the popup is currently open. Use when controlled.

defaultOpen?boolean

Whether the popup is initially open. To render a controlled popup, use the open prop instead.

Default
false
onOpenChange?(open: boolean, eventDetails: ComboboxRoot.OpenChangeEventDetails) → void

Event handler called when the popup is opened or closed.

Type
(open: boolean, eventDetails: ComboboxRoot.OpenChangeEventDetails) → void
Parameters

open – boolean

eventDetails – ComboboxRoot.OpenChangeEventDetails

Returns
void
value?ComboboxInputValue<Value, Multiple> | null

The selected value of the combobox. Use when controlled.

Type
ComboboxInputValue<Value, Multiple> | null
defaultValue?ComboboxInputValue<Value, Multiple> | null

The uncontrolled selected value of the combobox when it's initially rendered. To render a controlled combobox, use the value prop instead.

Type
ComboboxInputValue<Value, Multiple> | null
Default
[]
onValueChange?(value: ComboboxOutputValue<Value, Multiple> | (Multiple extends true ? never : null), eventDetails: ComboboxRoot.ChangeEventDetails) → void

Event handler called when the selected value of the combobox changes.

Type
(value: ComboboxOutputValue<Value, Multiple> | (Multiple extends true ? never : null), eventDetails: ComboboxRoot.ChangeEventDetails) → void
Parameters

value – ComboboxOutputValue<Value

Multiple> | (Multiple extends true ? never – null)

eventDetails – ComboboxRoot.ChangeEventDetails

Returns
void
actionsRef?React.RefObject<ComboboxRoot.Actions | null>

A ref to imperative actions. - unmount: Ends the closing phase of the combobox after an externally controlled closing animation finishes. Call preventUnmountOnClose() in onOpenChange first, otherwise the combobox completes closing on its own. Whether it leaves the DOM is decided by keepMounted on the portal. - close: Closes the combobox imperatively when called.

Type
React.RefObject<ComboboxRoot.Actions | null>
autoComplete?string

Provides a hint to the browser for autofill.

autoHighlight?boolean

Whether the first matching item is highlighted automatically while filtering.

Default
false
disabled?boolean

Whether the component should ignore user interaction.

Default
false
filter?null | ((item: Item, query: string, itemToString?: (item: Item) → string) → boolean)

Filter function used to match items vs input query. Receives the source item, which is the derived value's item when items is a createItems() collection, and the item itself otherwise.

Type
null | ((item: Item, query: string, itemToString?: (item: Item) → string) → boolean)
filteredItems?readonly Item[] | readonly Group<Item>[]

Filtered items to display in the list. When provided, the list uses these items instead of filtering the items prop internally. When items is also provided, this array must preserve its flat or grouped structure. With a createItems() collection, pass source items rather than derived values. Nullish entries are not supported, as in items. Use when you want to control filtering logic externally with the useFilter() hook.

Type
readonly Item[] | readonly Group<Item>[]
form?string

Identifies the form that owns the internal input. Useful when the combobox is rendered outside the form.

grid?boolean

Whether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows.

Default
false
highlightItemOnHover?boolean

Whether moving the pointer over items should highlight them. Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state.

Default
true
id?string

The id of the component.

inline?boolean

Whether 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.

Default
false
inputRef?React.Ref<HTMLInputElement>

A ref to the hidden input element.

Type
React.Ref<HTMLInputElement>
isItemEqualToValue?(itemValue: Value, value: Value) → boolean

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. With a createItems() collection, both arguments are derived values. Defaults to Object.is comparison.

Type
(itemValue: Value, value: Value) → boolean
Parameters

itemValue – Value

value – Value

Returns
boolean
items?readonly any[] | readonly Group<any>[] | ComboboxItemCollection<Item, ItemValue>

The items to be displayed in the list. Can be a flat array of items, an array of groups with items, or a collection created by the createItems() function, which derives each item's selection value and label. Nullish entries are not supported: remove them from the data before passing it.

Type
readonly any[] | readonly Group<any>[] | ComboboxItemCollection<Item, ItemValue>
itemToStringLabel?(itemValue: Value) → string

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. With a createItems() collection, this receives the derived value, and the collection's getLabel takes precedence for values it can resolve.

Parameters

itemValue – Value

Returns
string
itemToStringValue?(itemValue: Value) → string

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. With a createItems() collection, this receives the derived value.

Parameters

itemValue – Value

Returns
string
limit?number

The maximum number of items to display in the list.

Default
-1
locale?Intl.LocalesArgument

The locale to use for string comparison. Defaults to the user's runtime locale.

loopFocus?boolean

Whether 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>.

Default
true
modal?boolean

Determines 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. On touch devices, a true modal blocks outside taps but leaves the page scrollable unless the popup spans nearly the full viewport width, matching native iOS behavior.

Default
false
multiple?Multiple

Whether multiple items can be selected.

Default
false
name?string

Identifies the field when a form is submitted.

onItemHighlighted?(highlightedValue: Value, eventDetails: ComboboxRoot.HighlightEventDetails) → void

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. The event may be a MouseEvent rather than a PointerEvent. - none: the highlight changed for another reason, such as typing, autoHighlight, the item list changing, or the popup opening or closing.

Type
(highlightedValue: Value, eventDetails: ComboboxRoot.HighlightEventDetails) → void
Parameters

highlightedValue – Value

eventDetails – ComboboxRoot.HighlightEventDetails

Returns
void
onOpenChangeComplete?(open: boolean) → void

Event handler called after any animations complete when the popup is opened or closed.

Parameters

open – boolean

Returns
void
openOnInputClick?boolean

Whether the popup opens when clicking the input.

Default
true
readOnly?boolean

Whether the user should be unable to choose a different option from the popup.

Default
false
required?boolean

Whether the user must choose a value before submitting a form.

Default
false
virtualized?boolean

Whether the items are being externally virtualized.

Default
false
AttributeType
data-invalid?string

Present when invalid is true.

data-readonly?string

Present when readOnly is true.

ComboboxChipsInput

<input> data-slot="combobox-chip-input"

PropType
disabled?boolean

Whether the component should ignore user interaction.

Default
false
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

AttributeType
data-autofocus?string

Present when autoFocus is true.

data-invalid?string

Present when invalid is true.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

ComboboxItem

<div> data-slot="combobox-item"

PropType
disabled?boolean

Whether the component should ignore user interaction.

Default
false
index?number

The index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM.

nativeButton?boolean

Whether 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.

Default
false
onClick?React.MouseEventHandler

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.

value?any

A unique value that identifies this item.

Default
null
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

AttributeType
data-disabled?string

Present when disabled is true.

data-highlighted?string

Present when highlighted is true.

data-state"checked" | "unchecked"

"checked" or "unchecked".

Type
"checked" | "unchecked"
data-valueboolean

Value of value.

ComboboxItemIndicator

<span>

PropType
keepMounted?boolean

Whether to keep the HTML element in the DOM when the item is not selected.

Default
false
AttributeType
data-state"checked" | "unchecked"

"checked" or "unchecked".

Type
"checked" | "unchecked"

ComboboxList

<div> data-slot="combobox-list"

PropType
children?React.ReactNode | ((item: any, index: number) → React.ReactNode)

A function that gets item and returns what it renders.

Type
React.ReactNode | ((item: any, index: number) → React.ReactNode)
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

AttributeType
data-empty?string

Present when there are no items.

ComboboxPositioner

<div>

PropType
align?"start" | "center" | "end"

How to align the popup relative to the specified side.

Type
"start" | "center" | "end"
Default
"center"
alignOffset?number | OffsetFunction

Additional 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. ``jsx <Positioner alignOffset={({ side, align, anchor, positioner }) => { return side === top || side === bottom ? anchor.width : anchor.height; }} /> ``

Type
number | OffsetFunction
Default
0
anchor?Element | null | VirtualElement | React.RefObject<Element | null> | (() → Element | VirtualElement | null)

An element to position the popup against. By default, the popup will be positioned against the trigger.

Type
Element | null | VirtualElement | React.RefObject<Element | null> | (() → Element | VirtualElement | null)
arrowPadding?number

Minimum distance to maintain between the arrow and the edges of the popup. Use it to prevent the arrow element from hanging out of the rounded corners of a popup.

Default
5
collisionAvoidance?SideFlipMode | SideShiftMode

Determines how to handle collisions when positioning the popup. side controls overflow on the preferred placement axis (top/bottom or left/right): - flip: keep the requested side when it fits; otherwise try the opposite side (top and bottom, or left and right). - shift: never change side; keep the requested side and move the popup within the clipping boundary so it stays visible. - none: do not correct side-axis overflow. align controls overflow on the alignment axis (start/center/end): - flip: keep side, but swap start and end when the requested alignment overflows. - shift: keep side and requested alignment, then nudge the popup along the alignment axis to fit. - none: do not correct alignment-axis overflow. fallbackAxisSide controls fallback behavior on the perpendicular axis when the preferred axis cannot fit: - start: allow perpendicular fallback and try the logical start side first (top before bottom, or left before right in LTR). - end: allow perpendicular fallback and try the logical end side first (bottom before top, or right before left in LTR). - none: do not fallback to the perpendicular axis. When side is shift, explicitly setting align only supports shift or none. If align is omitted, it defaults to flip. ``jsx <Positioner collisionAvoidance={{ side: shift, align: shift, fallbackAxisSide: none, }} /> ``

Type
SideFlipMode | SideShiftMode
collisionBoundary?"clipping-ancestors" | Element | Element[] | Rect

An element or a rectangle that delimits the area that the popup is confined to.

Type
"clipping-ancestors" | Element | Element[] | Rect
Default
"clipping-ancestors"
collisionPadding?Padding

Additional space to maintain from the edge of the collision boundary.

Default
5
disableAnchorTracking?boolean

Whether to disable the popup from tracking any layout shift of its positioning anchor.

Default
false
positionMethod?"absolute" | "fixed"

Determines which CSS position property to use.

Type
"absolute" | "fixed"
Default
"absolute"
side?"top" | "bottom" | "left" | "right" | "inline-end" | "inline-start"

Which side of the anchor element to align the popup against. May automatically change to avoid collisions.

Type
"top" | "bottom" | "left" | "right" | "inline-end" | "inline-start"
Default
"bottom"
sideOffset?number | OffsetFunction

Distance 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. ``jsx <Positioner sideOffset={({ side, align, anchor, positioner }) => { return side === top || side === bottom ? anchor.height : anchor.width; }} /> ``

Type
number | OffsetFunction
Default
0
sticky?boolean

Whether to maintain the popup in the viewport after the anchor element was scrolled out of view.

Default
false
CSS variableType
--anchor-widthstring

The anchor's width.

--available-heightstring

The height left between the anchor and the viewport's edge.

--available-widthstring

The width left between the anchor and the viewport's edge.

--transform-originstring

Where the content scales from, on its trigger's side.

ComboboxTrigger

<button> data-slot="combobox-trigger"

PropType
disabled?boolean

Whether the component should ignore user interaction.

Default
false
nativeButton?boolean

Whether 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>).

Default
true
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

ComboboxValue

data-slot="combobox-value"

PropType
children?React.ReactNode | ((selectedValue: any) → React.ReactNode)

Accepts a function that returns a ReactNode to format the selected value. Treat the value as read-only: in multiple mode it may be a shared frozen array when nothing is selected.

Type
React.ReactNode | ((selectedValue: any) → React.ReactNode)
placeholder?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.

ComboboxClear

<button> data-slot="combobox-clear"

PropType
disabled?boolean

Whether the component should ignore user interaction.

Default
false
keepMounted?boolean

Whether the component should remain mounted in the DOM when not visible.

Default
false
nativeButton?boolean

Whether 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>).

Default
true
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

ComboboxInput

<input>

PropType
disabled?boolean

Whether the component should ignore user interaction.

Default
false
showClear?boolean

Shows a button that clears the input.

Default
false
showTrigger?boolean

Shows the button that opens the list.

Default
true
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

AttributeType
data-autofocus?string

Present when autoFocus is true.

data-invalid?string

Present when invalid is true.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

ComboboxContent

<div> data-slot="combobox-content"

PropType
finalFocus?boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) → void | boolean | HTMLElement | null)

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.

Type
boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) → void | boolean | HTMLElement | null)
initialFocus?boolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) → void | boolean | HTMLElement | null)

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.

Type
boolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) → void | boolean | HTMLElement | null)
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

AttributeType
data-chips?string
CSS variableType
--anchor-widthstring

The anchor's width.

--available-heightstring

The height left between the anchor and the viewport's edge.

--available-widthstring

The width left between the anchor and the viewport's edge.

--transform-originstring

Where the content scales from, on its trigger's side.

ComboboxGroup

<div> data-slot="combobox-group"

PropType
items?readonly any[]

Items to be rendered within this group. When provided, child Collection components will use these items.

render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

ComboboxLabel

<div> data-slot="combobox-label"

PropType
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

ComboboxCollection

data-slot="combobox-collection"

PropType
children(item: any, index: number) → React.ReactNode

A function that gets item and returns what it renders.

Type
(item: any, index: number) → React.ReactNode
Parameters

item – any

index – number

Returns
React.ReactNode

ComboboxEmpty

<div> data-slot="combobox-empty"

PropType
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

ComboboxSeparator

<div> data-slot="combobox-separator"

PropType
orientation?"horizontal" | "vertical"

The orientation of the separator.

Type
"horizontal" | "vertical"
Default
"horizontal"
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

ComboboxChips

<div> data-slot="combobox-chips"

PropType
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

ComboboxChip

<div> data-slot="combobox-chip"

PropType
showRemove?boolean

Shows a button that removes the chip.

Default
true
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.