Skip to content

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

Components

Free

Combobox for Ark UI

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 Ark 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 { useListCollection } from "@ark-ui/react/collection";
import { useFilter } from "@ark-ui/react/locale";
import {
  Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem,
  ComboboxList,
} from "@/components/ui/combobox";

Ark UI doesn't filter on its own. useListCollection holds the options, and calling its filter from onInputValueChange narrows them as people type.

const frameworks = ["Next.js", "SvelteKit", "Nuxt.js", "Remix", "Astro"];

const ComboboxDemo = () => {
  const { contains } = useFilter({ sensitivity: "base" });
  const { collection, filter } = useListCollection({
    filter: contains,
    initialItems: frameworks,
  });

  const handleInputValueChange = ({ inputValue }: { inputValue: string }) => {
    filter(inputValue);
  };

  return (
    <Combobox
      collection={collection}
      onInputValueChange={handleInputValueChange}
    >
      <ComboboxInput aria-label="Framework" placeholder="Select a framework" />
      <ComboboxContent>
        <ComboboxEmpty>No items found.</ComboboxEmpty>
        <ComboboxList>
          {collection.items.map((item) => (
            <ComboboxItem item={item} key={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, so typing never stops. The chevron and clear buttons carry labels of their own. Naming the field is up to you: use ComboboxLabel, which Ark UI ties to the input, put the combobox in a Field with a FieldLabel, or give the text field an aria-label, as most demos here do.

Arrow Down
When the combobox is closed, opens the listbox and highlights to the first option. When the combobox is open, moves focus to the next option.
Arrow Up
When the combobox is closed, opens the listbox and highlights to the last option. When the combobox is open, moves focus to the previous option.
Home
When the combobox is open, moves focus to the first option.
End
When the combobox is open, moves focus to the last option.
Escape
Closes the listbox.
Enter
Selects the highlighted option and closes the combobox.

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. The chips are yours to render: each one comes from the combobox's selectedItems and calls clearValue with its item when its remove button is pressed. 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. groupBy in useListCollection groups them, and each heading comes from the heading prop on 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 both Combobox and ComboboxInput turns off the whole field, 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

inputBehavior set to 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. selectionBehavior set to clear empties that field after each pick, so the next search starts fresh while the button shows the choice. 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. Ark UI positions the popup against the whole field, icon included, so it starts at the field's edge with no offset, widened to 240 pixels for the longer city names. 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, inside a Direction provider set to right to left. Ark UI takes the direction from the locale rather than a dir attribute, so the provider is what turns the chips, the text field and the list around, and dir set to rtl on the Field lays out its label.

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?

Ark UI leaves filtering to you. Build the options with useListCollection and a filter such as contains from useFilter, then call the filter it returns from onInputValueChange with the new inputValue, as every demo here does. Pass the resulting collection to Combobox and render its items.

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

Fetch from onInputValueChange and pass the results to the set function from useListCollection instead of calling filter, since the server has already matched them. Show a loading row inside ComboboxContent while the request runs.

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 array holds every pick. The chips are yours: inside ComboboxChips, render a ComboboxChip for each of the combobox's selectedItems, call clearValue with that item from its remove button, and end the row with ComboboxFieldInput, as the Multiple demo does.

How do I control the Combobox value in React?

Hold an array of item values in state, pass it as value and update it from onValueChange, whose details carry value and the matching items. The array holds one entry in a single combobox. The typed text is separate, and inputValue with onInputValueChange controls it.

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

Yes. Add allowCustomValue to Combobox, and text that matches no option stays in the field when it loses focus instead of reverting. It isn't added to the value, though, so read it from inputValue and decide what to do with it.

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, as the demos do. Ark UI renders it only when the collection has no items left, and with no text of its own the wrapper says "No results found."

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, but know what it sends: Ark UI puts the name on the text field itself, so the form gets the text in the input, the chosen option's label rather than its value. To send the value, add a hidden input that holds the selection from state. In a multiple combobox the text field empties after each pick, so hidden inputs are the only way to submit the choices.

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

<div> data-slot="combobox"

PropType
inputValue?string

The controlled value of the combobox's input.

defaultInputValue?string

The initial value of the combobox's input when rendered. Use when you don't need to control the value of the combobox's input.

Default
""
onInputValueChange?(details: InputValueChangeDetails) → void

Function called when the input's value changes.

Type
(details: InputValueChangeDetails) → void
Parameters

details – { inputValue: string; reason?: InputValueChangeReason }

Returns
void
open?boolean

The controlled open state of the combobox.

defaultOpen?boolean

The initial open state of the combobox when rendered. Use when you don't need to control the open state of the combobox.

onOpenChange?(details: OpenChangeDetails) → void

Function called when the popup is opened.

Type
(details: OpenChangeDetails) → void
Parameters

details – { open: boolean; reason?: OpenChangeReason; value: string[] }

Returns
void
value?string[]

The controlled value of the combobox's selected items.

defaultValue?string[]

The initial value of the combobox's selected items when rendered. Use when you don't need to control the value of the combobox's selected items.

Default
[]
onValueChange?(details: ValueChangeDetails<T>) → void

Function called when a new item is selected.

Type
(details: ValueChangeDetails<T>) → void
Parameters

details – ValueChangeDetails<T>

Returns
void
collectionListCollection<T>

The collection of items.

Type
ListCollection<T>
allowCustomValue?boolean

Whether to allow typing custom values in the input.

alwaysSubmitOnEnter?boolean

Whether to always submit on Enter key press, even if popup is open. Useful for single-field autocomplete forms where Enter should submit the form.

Default
false
autoFocus?boolean

Whether to autofocus the input on mount.

closeOnSelect?boolean

Whether to close the combobox when an item is selected.

composite?boolean

Whether the combobox is a composed with other composite widgets like tabs.

Default
true
defaultHighlightedValue?string | null

The initial highlighted value of the combobox when rendered. Use when you don't need to control the highlighted value of the combobox.

Type
string | null
dir?"ltr" | "rtl"

The document's text/writing direction.

Type
"ltr" | "rtl"
Default
"ltr"
disabled?boolean

Whether the combobox is disabled.

disableLayer?boolean

Whether to disable registering this a dismissable layer.

form?string

The associate form of the combobox.

hideMode?"display-none" | "activity"

How to hide content when mounted but not present. - display-none: HTML hidden attribute. Effects stay alive. - activity: React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.

Type
"display-none" | "activity"
Default
"display-none"
highlightedValue?string | null

The controlled highlighted value of the combobox.

Type
string | null
id?string

The unique identifier of the machine.

ids?object

The ids of the elements in the combobox. Useful for composition.

Type
{ root?: string; label?: string; control?: string; input?: string; content?: string; trigger?: string; clearTrigger?: string; item?: (id: string, index?: number) → string; positioner?: string; itemGroup?: (id: string | number) → string; itemGroupLabel?: (id: string | number) → string }
immediate?boolean

Whether to synchronize the present change immediately or defer it to the next frame.

inputBehavior?"autohighlight" | "autocomplete" | "none"

Defines the auto-completion behavior of the combobox. - autohighlight: The first focused item is highlighted as the user types - autocomplete: Navigating the listbox with the arrow keys selects the item and the input is updated

Type
"autohighlight" | "autocomplete" | "none"
Default
"none"
invalid?boolean

Whether the combobox is invalid.

lazyMount?boolean

Whether to enable lazy mounting. Ark default: false.

Default
true
loopFocus?boolean

Whether to loop the keyboard navigation through the items.

Default
true
multiple?boolean

Whether to allow multiple selection. **Good to know:** When multiple is true, the selectionBehavior is automatically set to clear. It is recommended to render the selected items in a separate container.

name?string

The name attribute of the combobox's input. Useful for form submission.

navigate?((details: NavigateDetails) → void) | null

Function to navigate to the selected item.

Type
((details: NavigateDetails) → void) | null
Parameters

(details – { value: string; node: HTMLAnchorElement; href: string }

Returns
void) | null
onEnterComplete?VoidFunction

Function called when the animation ends in the open state.

onExitComplete?VoidFunction

Function called when the animation ends in the closed state.

onFocusOutside?(event: FocusOutsideEvent) → void

Function called when the focus is moved outside the component.

Type
(event: FocusOutsideEvent) → void
Parameters

event – FocusOutsideEvent

Returns
void
onHighlightChange?(details: HighlightChangeDetails<T>) → void

Function called when an item is highlighted using the pointer or keyboard navigation.

Type
(details: HighlightChangeDetails<T>) → void
Parameters

details – HighlightChangeDetails<T>

Returns
void
onInteractOutside?(event: InteractOutsideEvent) → void

Function called when an interaction happens outside the component.

Type
(event: InteractOutsideEvent) → void
Parameters

event – InteractOutsideEvent

Returns
void
onPointerDownOutside?(event: PointerDownOutsideEvent) → void

Function called when the pointer is pressed down outside the component.

Type
(event: PointerDownOutsideEvent) → void
Parameters

event – PointerDownOutsideEvent

Returns
void
onSelect?(details: SelectionDetails) → void

Function called when an item is selected.

Type
(details: SelectionDetails) → void
Parameters

details – { value: string[]; itemValue: string }

Returns
void
openOnChange?boolean | ((details: InputValueChangeDetails) → boolean)

Whether to show the combobox when the input value changes.

Type
boolean | ((details: InputValueChangeDetails) → boolean)
Default
true
openOnClick?boolean

Whether to open the combobox popup on initial click on the input. Ark default: false.

Default
true
openOnKeyPress?boolean

Whether to open the combobox on arrow key press.

Default
true
placeholder?string

The placeholder text of the combobox's input.

positioning?object

The positioning options to dynamically position the menu.

Type
{ restoreStyles?: boolean; applyStyles?: boolean; hideWhenDetached?: boolean; strategy?: "absolute" | "fixed"; placement?: Placement; offset?: { mainAxis?: number; crossAxis?: number; }; gutter?: number; shift?: number; overflowPadding?: number; arrowPadding?: number; flip?: boolean | Placement[]; slide?: boolean; overlap?: boolean; sameWidth?: boolean; fitViewport?: boolean; sizeMiddleware?: boolean; boundary?: (() → Boundary) | Boundary | "clipping-ancestors"; listeners?: boolean | AutoUpdateOptions; onComplete?: (data: ComputePositionReturn) → void; onPositioned?: ((data: { placed: boolean; }) → void); getAnchorElement?: () → HTMLElement | VirtualElement | null; getAnchorRect?: (element: HTMLElement | VirtualElement | null) → AnchorRect | null; updatePosition?: ((data: { updatePosition: () → Promise<void>; floatingElement: HTMLElement | null; }) → void | Promise<void>) }
Default
{ placement: "bottom-start" }
present?boolean

Whether the node is present (controlled by the user).

readOnly?boolean

Whether the combobox is readonly. This puts the combobox in a "non-editable" mode but the user can still interact with it

required?boolean

Whether the combobox is required.

scrollToIndexFn?(details: ScrollToIndexDetails) → void

Function to scroll to a specific index.

Type
(details: ScrollToIndexDetails) → void
Parameters

details – { index: number; immediate?: boolean; getElement: () → HTMLElement | null }

Returns
void
selectionBehavior?"clear" | "replace" | "preserve"

The behavior of the combobox input when an item is selected - replace: The selected item string is set as the input value - clear: The input value is cleared - preserve: The input value is preserved

Type
"clear" | "replace" | "preserve"
Default
"replace"
skipAnimationOnMount?boolean

Whether to allow the initial presence animation.

Default
false
translations?object

Specifies the localized strings that identifies the accessibility elements and their states.

Type
{ triggerLabel?: string; clearTriggerLabel?: string }
unmountOnExit?boolean

Whether to unmount on exit. Ark default: false.

Default
true
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

AttributeType
data-invalid?string

Present when invalid.

data-readonly?string

Present when read-only.

ComboboxClear

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

AttributeType
data-invalid?string

Present when invalid.

ComboboxContent

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-empty?string

Present when the content is empty.

data-has-nested?string

Present when another listbox is nested inside it.

data-nested?string

Present when it's nested inside another listbox.

data-placementstring

The placement of the content.

data-side"top" | "right" | "bottom" | "left"

The side of the trigger that the content is positioned on.

Type
"top" | "right" | "bottom" | "left"
data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"
CSS variableType
--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.

--layer-indexstring

The index of the dismissable in the layer stack.

--nested-layer-countstring

The number of nested comboboxs.

--reference-widthstring

The trigger's width.

--transform-originstring

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

ComboboxChips

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-disabled?string

Present when disabled.

data-focus?string

Present when focused.

data-invalid?string

Present when invalid.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

ComboboxFieldInput

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

AttributeType
data-autofocus?string

Present when autoFocus is true.

data-invalid?string

Present when invalid.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

ComboboxItem

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

PropType
itemany

The item to render.

persistFocus?boolean

Whether hovering outside should clear the highlighted state.

showIndicator?boolean

Shows the selected item's check at the row's end, with room kept for it.

Default
true
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-disabled?string

Present when disabled.

data-highlighted?string

Present when highlighted.

data-state"checked" | "unchecked"

"checked" or "unchecked".

Type
"checked" | "unchecked"
data-valueboolean

The value of the item.

ComboboxGroup

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

PropType
heading?string | React.ReactNode

The heading of the group.

Type
string | React.ReactNode
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

AttributeType
data-empty?string

Present when the content is empty.

ComboboxGroupLabel

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

ComboboxItemIndicator

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

AttributeType
data-state"checked" | "unchecked"

"checked" or "unchecked".

Type
"checked" | "unchecked"

ComboboxLabel

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-disabled?string

Present when disabled.

data-focus?string

Present when focused.

data-invalid?string

Present when invalid.

data-readonly?string

Present when read-only.

data-required?string

Present when required.

ComboboxList

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-empty?string

Present when the content is empty.

ComboboxPositioner

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-has-nested?string

Present when the positioner has nested comboboxs.

data-nested?string

Present when the positioner is nested within another combobox.

CSS variableType
--available-heightstring

The available height in viewport.

--available-widthstring

The available width in viewport.

--reference-heightstring

The height of the root.

--reference-widthstring

The width of the reference element.

--transform-originstring

The transform origin for animations.

--xstring

The x position for transform.

--ystring

The y position for transform.

--z-indexstring

The z-index value.

ComboboxTrigger

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

PropType
focusable?boolean

Whether the trigger is focusable.

asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-disabled?string

Present when disabled.

data-focusable?string
data-invalid?string

Present when invalid.

data-readonly?string

Present when read-only.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

ComboboxControl

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-disabled?string

Present when disabled.

data-focus?string

Present when focused.

data-invalid?string

Present when invalid.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

ComboboxInput

<input>

PropType
disabled?boolean

Whether the control is disabled.

Default
false
showClear?boolean

Whether to show the clear button.

Default
false
showTrigger?boolean

Whether to show the trigger button.

Default
true
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-autofocus?string

Present when autoFocus is true.

data-invalid?string

Present when invalid.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"

ComboboxEmpty

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

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

ComboboxSeparator

data-slot="combobox-separator"

PropType
orientation?"horizontal" | "vertical"

The orientation of the separator.

Type
"horizontal" | "vertical"
Default
"horizontal"
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

className?string

Merged with the part's classes.

AttributeType
data-invalid?string

Present when invalid is true.

data-readonly?string

Present when readOnly is true.

ComboboxChip

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

PropType
className?string

Merged with the part's classes.

ComboboxRootProvider

<div> data-slot="combobox"

PropType
valueUseComboboxReturn<T>

What useCombobox() returns: the state and API, made outside the component to control it.

Type
UseComboboxReturn<T>
hideMode?"display-none" | "activity"

How to hide content when mounted but not present. - display-none: HTML hidden attribute. Effects stay alive. - activity: React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.

Type
"display-none" | "activity"
Default
"display-none"
immediate?boolean

Whether to synchronize the present change immediately or defer it to the next frame.

lazyMount?boolean

Whether to enable lazy mounting. Ark default: false.

Default
true
onEnterComplete?VoidFunction

Function called when the animation ends in the open state.

onExitComplete?VoidFunction

Function called when the animation ends in the closed state.

present?boolean

Whether the node is present (controlled by the user).

skipAnimationOnMount?boolean

Whether to allow the initial presence animation.

Default
false
unmountOnExit?boolean

Whether to unmount on exit. Ark default: false.

Default
true
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

AttributeType
data-invalid?string

Present when invalid is true.

data-readonly?string

Present when readOnly is true.

useCombobox

PropType
inputValue?string

The controlled value of the combobox's input.

defaultInputValue?string

The initial value of the combobox's input when rendered. Use when you don't need to control the value of the combobox's input.

Default
""
onInputValueChange?(details: InputValueChangeDetails) → void

Function called when the input's value changes.

Type
(details: InputValueChangeDetails) → void
Parameters

details – { inputValue: string; reason?: InputValueChangeReason }

Returns
void
open?boolean

The controlled open state of the combobox.

defaultOpen?boolean

The initial open state of the combobox when rendered. Use when you don't need to control the open state of the combobox.

onOpenChange?(details: OpenChangeDetails) → void

Function called when the popup is opened.

Type
(details: OpenChangeDetails) → void
Parameters

details – { open: boolean; reason?: OpenChangeReason; value: string[] }

Returns
void
value?string[]

The controlled value of the combobox's selected items.

defaultValue?string[]

The initial value of the combobox's selected items when rendered. Use when you don't need to control the value of the combobox's selected items.

Default
[]
onValueChange?(details: ValueChangeDetails<T>) → void

Function called when a new item is selected.

Type
(details: ValueChangeDetails<T>) → void
Parameters

details – ValueChangeDetails<T>

Returns
void
collectionListCollection<T>

The collection of items.

Type
ListCollection<T>
allowCustomValue?boolean

Whether to allow typing custom values in the input.

alwaysSubmitOnEnter?boolean

Whether to always submit on Enter key press, even if popup is open. Useful for single-field autocomplete forms where Enter should submit the form.

Default
false
autoFocus?boolean

Whether to autofocus the input on mount.

closeOnSelect?boolean

Whether to close the combobox when an item is selected.

composite?boolean

Whether the combobox is a composed with other composite widgets like tabs.

Default
true
defaultHighlightedValue?string | null

The initial highlighted value of the combobox when rendered. Use when you don't need to control the highlighted value of the combobox.

Type
string | null
disabled?boolean

Whether the combobox is disabled.

disableLayer?boolean

Whether to disable registering this a dismissable layer.

form?string

The associate form of the combobox.

highlightedValue?string | null

The controlled highlighted value of the combobox.

Type
string | null
id?string

The unique identifier of the machine.

ids?object

The ids of the elements in the combobox. Useful for composition.

Type
{ root?: string; label?: string; control?: string; input?: string; content?: string; trigger?: string; clearTrigger?: string; item?: (id: string, index?: number) → string; positioner?: string; itemGroup?: (id: string | number) → string; itemGroupLabel?: (id: string | number) → string }
inputBehavior?"autohighlight" | "autocomplete" | "none"

Defines the auto-completion behavior of the combobox. - autohighlight: The first focused item is highlighted as the user types - autocomplete: Navigating the listbox with the arrow keys selects the item and the input is updated

Type
"autohighlight" | "autocomplete" | "none"
Default
"none"
invalid?boolean

Whether the combobox is invalid.

loopFocus?boolean

Whether to loop the keyboard navigation through the items.

Default
true
multiple?boolean

Whether to allow multiple selection. **Good to know:** When multiple is true, the selectionBehavior is automatically set to clear. It is recommended to render the selected items in a separate container.

name?string

The name attribute of the combobox's input. Useful for form submission.

navigate?((details: NavigateDetails) → void) | null

Function to navigate to the selected item.

Type
((details: NavigateDetails) → void) | null
Parameters

(details – { value: string; node: HTMLAnchorElement; href: string }

Returns
void) | null
onFocusOutside?(event: FocusOutsideEvent) → void

Function called when the focus is moved outside the component.

Type
(event: FocusOutsideEvent) → void
Parameters

event – FocusOutsideEvent

Returns
void
onHighlightChange?(details: HighlightChangeDetails<T>) → void

Function called when an item is highlighted using the pointer or keyboard navigation.

Type
(details: HighlightChangeDetails<T>) → void
Parameters

details – HighlightChangeDetails<T>

Returns
void
onInteractOutside?(event: InteractOutsideEvent) → void

Function called when an interaction happens outside the component.

Type
(event: InteractOutsideEvent) → void
Parameters

event – InteractOutsideEvent

Returns
void
onPointerDownOutside?(event: PointerDownOutsideEvent) → void

Function called when the pointer is pressed down outside the component.

Type
(event: PointerDownOutsideEvent) → void
Parameters

event – PointerDownOutsideEvent

Returns
void
onSelect?(details: SelectionDetails) → void

Function called when an item is selected.

Type
(details: SelectionDetails) → void
Parameters

details – { value: string[]; itemValue: string }

Returns
void
openOnChange?boolean | ((details: InputValueChangeDetails) → boolean)

Whether to show the combobox when the input value changes.

Type
boolean | ((details: InputValueChangeDetails) → boolean)
Default
true
openOnClick?boolean

Whether to open the combobox popup on initial click on the input.

Default
false
openOnKeyPress?boolean

Whether to open the combobox on arrow key press.

Default
true
placeholder?string

The placeholder text of the combobox's input.

positioning?object

The positioning options to dynamically position the menu.

Type
{ restoreStyles?: boolean; applyStyles?: boolean; hideWhenDetached?: boolean; strategy?: "absolute" | "fixed"; placement?: Placement; offset?: { mainAxis?: number; crossAxis?: number; }; gutter?: number; shift?: number; overflowPadding?: number; arrowPadding?: number; flip?: boolean | Placement[]; slide?: boolean; overlap?: boolean; sameWidth?: boolean; fitViewport?: boolean; sizeMiddleware?: boolean; boundary?: (() → Boundary) | Boundary | "clipping-ancestors"; listeners?: boolean | AutoUpdateOptions; onComplete?: (data: ComputePositionReturn) → void; onPositioned?: ((data: { placed: boolean; }) → void); getAnchorElement?: () → HTMLElement | VirtualElement | null; getAnchorRect?: (element: HTMLElement | VirtualElement | null) → AnchorRect | null; updatePosition?: ((data: { updatePosition: () → Promise<void>; floatingElement: HTMLElement | null; }) → void | Promise<void>) }
Default
{ placement: "bottom-start" }
readOnly?boolean

Whether the combobox is readonly. This puts the combobox in a "non-editable" mode but the user can still interact with it

required?boolean

Whether the combobox is required.

scrollToIndexFn?(details: ScrollToIndexDetails) → void

Function to scroll to a specific index.

Type
(details: ScrollToIndexDetails) → void
Parameters

details – { index: number; immediate?: boolean; getElement: () → HTMLElement | null }

Returns
void
selectionBehavior?"clear" | "replace" | "preserve"

The behavior of the combobox input when an item is selected - replace: The selected item string is set as the input value - clear: The input value is cleared - preserve: The input value is preserved

Type
"clear" | "replace" | "preserve"
Default
"replace"
translations?object

Specifies the localized strings that identifies the accessibility elements and their states.

Type
{ triggerLabel?: string; clearTriggerLabel?: string }

ComboboxContext

PropType
clearHighlightValueVoidFunction

Function to clear the highlighted value.

clearValue(value?: string) → void

Function to clear the value of the combobox.

Parameters

value? – string

Returns
void
collectionListCollection<V>

Function to toggle the combobox.

Type
ListCollection<V>
disabledboolean

Whether the combobox is disabled.

focusVoidFunction

Function to focus on the combobox input.

focusedboolean

Whether the combobox is focused.

getItemState(props: ItemProps) → ItemState

Returns the state of a combobox item.

Parameters

props – { persistFocus?: boolean; item: CollectionItem }

Returns
ItemState
hasSelectedItemsboolean

Whether there's a selected item.

highlightedItemV | null

The highlighted item.

Type
V | null
highlightedValuestring | null

The value of the highlighted item.

Type
string | null
inputValuestring

The value of the combobox input.

multipleboolean

Whether the combobox allows multiple selections.

openboolean

Whether the combobox is open.

reposition(options?: Partial<PositioningOptions>) → void

Function to set the positioning options.

Type
(options?: Partial<PositioningOptions>) → void
Parameters

options? – Partial<PositioningOptions>

Returns
void
selectedItemsV[]

The selected items.

selectValue(value: string) → void

Function to select a value.

Parameters

value – string

Returns
void
setHighlightValue(value: string) → void

The value of the combobox input.

Parameters

value – string

Returns
void
setInputValue(value: string, reason?: InputValueChangeReason) → void

Function to set the input value of the combobox.

Type
(value: string, reason?: InputValueChangeReason) → void
Parameters

value – string

reason? – InputValueChangeReason

Returns
void
setOpen(open: boolean, reason?: OpenChangeReason) → void

Function to open or close the combobox.

Type
(open: boolean, reason?: OpenChangeReason) → void
Parameters

open – boolean

reason? – OpenChangeReason

Returns
void
setValue(value: string[]) → void

Function to set the value of the combobox.

Parameters

value – string[]

Returns
void
syncSelectedItemsVoidFunction

Function to sync the selected items with the value. Useful when value is updated from async sources.

valuestring[]

The selected item keys.

valueAsStringstring

The string representation of the selected items.

ComboboxItemContext

PropType
disabledboolean

Whether the item is disabled.

highlightedboolean

Whether the item is highlighted via pointer or keyboard navigation.

selectedboolean

Whether the item is selected.

valuestring

The value of the item.