Combobox

A single input field that combines the functionality of a select and input.

Loading...

Anatomy

<Combobox.Root>
  <Combobox.Label />
  <Combobox.Control>
    <Combobox.Input />
    <Combobox.Trigger />
    <Combobox.ClearTrigger />
  </Combobox.Control>
  <Combobox.Positioner>
    <Combobox.Content>
      <Combobox.ItemGroup>
        <Combobox.ItemGroupLabel />
        <Combobox.Item>
          <Combobox.ItemText />
          <Combobox.ItemIndicator />
        </Combobox.Item>
      </Combobox.ItemGroup>
    </Combobox.Content>
  </Combobox.Positioner>
</Combobox.Root>

Examples

Auto Highlight

Set inputBehavior="autohighlight" to highlight the first match as the user types.

Inline Autocomplete

Set inputBehavior="autocomplete" to complete the input with the first match. It works best with a startsWith filter.

Grouping

Set groupBy on the collection and iterate the groups with collection.group().

Field

Wrap the combobox in Field to wire up the label, helper text and error text accessibly.

Context

Use Combobox.Context or the useComboboxContext hook to read the state, for example to show the selected value.

Root Provider

Use RootProvider with the useCombobox hook to access the state and methods from outside the component.

Use asChild to render items as links.

Rehydrate

When defaultValue or value is set before the collection loads, rehydrate the value to populate the input.

Highlight Text

Highlight the text in each item that matches the input.

Dynamic

Generate items from the user's input, for example as suggestions.

Creatable

Let users create an option when their search matches no item, for example for tags.

Multiple Selection

Set multiple to allow several selections. You can show selected items as tags above the input.

Use the useAsyncList hook to load options as the user types, for example from an API.

Textarea Mention

Use a textarea as the input and anchor the content to the caret to suggest mentions after typing @.

Virtualized

Render only the visible options with the Virtualizer. Render Combobox.List as ListVirtualizer.Root and each Combobox.Item as ListVirtualizer.Item. Keep the virtualizer's count in sync with the filtered collection. Pass scrollToIndexFn so keyboard navigation can reach options that aren't mounted yet.

Custom Object

Use itemToString and itemToValue to map custom objects.

Limit Results

Set limit on useListCollection to cap how many items render.

Guides

Pass navigate to Combobox.Root to use your router. With TanStack Router:

import { Combobox } from '@ark-ui/<framework>/combobox'
import { useNavigate } from '@tanstack/react-router'

function Demo() {
  const navigate = useNavigate()
  return (
    <Combobox.Root
      navigate={(e) => {
        navigate({ to: e.node.href })
      }}
    >
      {/* ... */}
    </Combobox.Root>
  )
}

Custom Objects

The collection expects objects with label and value by default. For other shapes, map them with itemToString and itemToValue.

const items = [
  { country: 'United States', code: 'US', flag: '🇺🇸' },
  { country: 'Canada', code: 'CA', flag: '🇨🇦' },
  { country: 'Australia', code: 'AU', flag: '🇦🇺' },
  // ...
]

const { collection } = useListCollection({
  initialItems: items,
  itemToString: (item) => item.country,
  itemToValue: (item) => item.code,
})

Type Safety

Type a wrapper with Combobox.RootComponent to keep collection items typed.

const Combobox: ArkCombobox.RootComponent = (props) => {
  return <ArkCombobox.Root {...props}>{/* ... */}</ArkCombobox.Root>
}

Callbacks like onValueChange then infer the item type:

const App = () => {
  const { collection } = useListCollection({
    initialItems: [
      { label: 'React', value: 'react' },
      { label: 'Vue', value: 'vue' },
    ],
  })
  return (
    <Combobox
      collection={collection}
      onValueChange={(e) => {
        // e.items is typed as Array<{ label: string, value: string }>
        console.log(e.items)
      }}
    >
      {/* ... */}
    </Combobox>
  )
}

Large Datasets

For large lists, set limit on useListCollection to cap how many items render.

const { collection } = useListCollection({
  initialItems: items,
  limit: 10,
})

Available Size

Combobox.Positioner exposes these CSS variables for styling Combobox.Content:

/* width of the combobox control */
--reference-width: <pixel-value>;
/* width of the available viewport */
--available-width: <pixel-value>;
/* height of the available viewport */
--available-height: <pixel-value>;

For example, keep the content within the available height:

[data-combobox-content] {
  max-height: calc(var(--available-height) - 100px);
}

API Reference

Props

Root

Defines the <div> element.

AttributeDefaultType
collection
ListCollection<T, never>

The collection of items

allowCustomValue
boolean

Whether to allow typing custom values in the input

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

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
autoFocus
boolean

Whether to autofocus the input on mount

closeOnSelect
boolean

Whether to close the combobox when an item is selected.

defaultHighlightedValue
string

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

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.

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.

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.

disabled
boolean

Whether the combobox is disabled

form
string

The associate form of the combobox.

hideMode'display-none'
HideMode

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

highlightedValue
string

The controlled highlighted value of the combobox

id
string

The unique identifier of the machine.

ids
Partial<{ root: string label: string control: string input: string content: string list: string trigger: string clearTrigger: string item: (id: string, index?: number | undefined) => string positioner: string itemGroup: (id: string | number) => string itemGroupLabel: (id: string | number) => string }>

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

immediate
boolean

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

inline
boolean

Whether the list renders inline: always open, not positioned or dismissable

inputBehavior'none'
'none' | 'autohighlight' | 'autocomplete'

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

inputValue
string

The controlled value of the combobox's input

invalid
boolean

Whether the combobox is invalid

lazyMountfalse
boolean

Whether to enable lazy mounting

loading
boolean

Whether the results are being loaded (e.g. fetched from a server). While loading, the listbox is marked with `aria-busy`, the loading message is announced instead of the result count, and "no results" is never announced.

loopFocustrue
boolean

Whether to loop the keyboard navigation through the items

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

Function to navigate to the selected item

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

onHighlightChange
(details: HighlightChangeDetails<T>) => void

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

onInputValueChange
(details: InputValueChangeDetails) => void

Function called when the input's value changes

onInteractOutside
(event: InteractOutsideEvent) => void

Function called when an interaction happens outside the component

onOpenChange
(details: OpenChangeDetails) => void

Function called when the popup is opened

onPointerDownOutside
(event: PointerDownOutsideEvent) => void

Function called when the pointer is pressed down outside the component

onSelect
(details: SelectionDetails) => void

Function called when an item is selected

onValueChange
(details: ValueChangeDetails<T>) => void

Function called when a new item is selected

open
boolean

The controlled open state of the combobox

openOnChangetrue
boolean | ((details: InputValueChangeDetails) => boolean)

Whether to show the combobox when the input value changes

openOnClickfalse
boolean

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

openOnKeyPresstrue
boolean

Whether to open the combobox on arrow key press

placeholder
string

The placeholder text of the combobox's input

popupType'listbox'
'dialog' | 'listbox'

The ARIA pattern of the popup. Drives `aria-haspopup` on the trigger, the `role` of the content element, the trigger's keyboard handling, and the label's click target. - `"listbox"` (default) — input-driven combobox; popup is a passive listbox. - `"dialog"` — popover-style combobox; popup is announced as a dialog, trigger is keyboard-active, label-click focuses the trigger.

positioning{ placement: 'bottom-start' }
PositioningOptions

The positioning options to dynamically position the menu

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

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<ComboboxRootState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

required
boolean

Whether the combobox is required

scrollToIndexFn
(details: ScrollToIndexDetails) => void

Function to scroll to a specific index

selectionBehavior'replace'
'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

skipAnimationOnMountfalse
boolean

Whether to allow the initial presence animation.

translations
IntlTranslations

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

unmountOnExitfalse
boolean

Whether to unmount on exit.

value
string[]

The controlled value of the combobox's selected items

AttributeDescription
[data-combobox-root]<uid>
[data-state]"open" | "closed"
[data-disabled]Present when disabled
[data-invalid]Present when invalid
[data-readonly]Present when read-only

ClearTrigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-clear-trigger]<uid>
[data-invalid]Present when invalid

Content

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<ComboboxContentState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-content]<uid>
[data-state]"open" | "closed"
[data-placement]The placement of the content
[data-side]The side of the trigger that the content is positioned on
[data-empty]Present when the content is empty
[data-inline]Present when the content is inline
[data-loading]Present when loading
[data-nested]listbox
[data-has-nested]listbox
CSS VariableDescription
--layer-indexThe index of the dismissable in the layer stack
--nested-layer-countThe number of nested comboboxs

Control

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-control]<uid>
[data-state]"open" | "closed"
[data-focus]Present when focused
[data-disabled]Present when disabled
[data-invalid]Present when invalid

Empty

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Input

Defines the <input> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-input]<uid>
[data-invalid]Present when invalid
[data-autofocus]
[data-state]"open" | "closed"

ItemGroupLabel

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

ItemGroup

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-item-group]<uid>
[data-empty]Present when the content is empty

ItemIndicator

Defines the <span> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-item-indicator]<uid>
[data-state]"checked" | "unchecked"

Item

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
item
any

The item to render

persistFocus
boolean

Whether hovering outside should clear the highlighted state

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<ComboboxItemState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-item]<uid>
[data-highlighted]Present when highlighted
[data-state]"checked" | "unchecked"
[data-disabled]Present when disabled
[data-value]The value of the item

ItemText

Defines the <span> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-item-text]<uid>
[data-state]"checked" | "unchecked"
[data-disabled]Present when disabled
[data-highlighted]Present when highlighted

Label

Defines the <label> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-label]<uid>
[data-readonly]Present when read-only
[data-disabled]Present when disabled
[data-invalid]Present when invalid
[data-required]Present when required
[data-focus]Present when focused

List

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-list]<uid>
[data-empty]Present when the content is empty
[data-loading]Present when loading

Positioner

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-positioner]<uid>
[data-nested]Present when the positioner is nested within another {{widget}}
[data-has-nested]Present when the positioner has nested {{widget}}s
CSS VariableDescription
--reference-widthThe width of the reference element
--reference-heightThe height of the root
--available-widthThe available width in viewport
--available-heightThe available height in viewport
--xThe x position for transform
--yThe y position for transform
--transform-originThe transform origin for animations

RootProvider

Defines the <div> element.

AttributeDefaultType
value
UseComboboxReturn<T>

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
hideMode'display-none'
HideMode

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

immediate
boolean

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

lazyMountfalse
boolean

Whether to enable lazy mounting

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)

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<ComboboxRootProviderState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

skipAnimationOnMountfalse
boolean

Whether to allow the initial presence animation.

unmountOnExitfalse
boolean

Whether to unmount on exit.

Status

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Trigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
focusable
boolean

Whether the trigger is focusable

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<ComboboxTriggerState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-combobox-trigger]<uid>
[data-state]"open" | "closed"
[data-invalid]Present when invalid
[data-focusable]
[data-readonly]Present when read-only
[data-disabled]Present when disabled

Context

API

PropertyType
focused
boolean

Whether the combobox is focused

open
boolean

Whether the combobox is open

inline
boolean

Whether the list renders inline

loading
boolean

Whether the results are being loaded

inputValue
string

The value of the combobox input

highlightedValue
string | null

The value of the highlighted item

highlightedItem
V | null

The highlighted item

setHighlightedValue
(value: string | null) => void

Function to highlight a value, or clear the highlight with `null`

syncSelectedItems
VoidFunction

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

selectedItems
V[]

The selected items

hasSelectedItems
boolean

Whether there's a selected item

value
string[]

The selected item keys

valueAsString
string

The string representation of the selected items

selectValue
(value: string) => void

Function to select a value

setValue
(value: string[]) => void

Function to set the value of the combobox

clearValue
(value?: string) => void

Function to clear the value of the combobox

focus
VoidFunction

Function to focus on the combobox input

setInputValue
(value: string, reason?: InputValueChangeReason) => void

Function to set the input value of the combobox

getItemState
(props: ItemProps) => ItemState

Returns the state of a combobox item

setOpen
(open: boolean, reason?: OpenChangeReason) => void

Function to open or close the combobox

collection
ListCollection<V>

Function to toggle the combobox

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

Function to set the positioning options

multiple
boolean

Whether the combobox allows multiple selections

disabled
boolean

Whether the combobox is disabled

getRootState
() => RootState

Returns the state of the root

getContentState
() => ContentState

Returns the state of the content

getTriggerState
(props?: TriggerProps) => TriggerState

Returns the state of the trigger

Accessibility

Complies with the Combobox WAI-ARIA design pattern.

Keyboard Support

KeyDescription
ArrowDown
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.
ArrowUp
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.
Esc
Closes the combobox