Components
Combobox

Combobox

An intelligent input box with a dropdown for suggesting possible options.

API reference docs for the component. Learn about the props, CSS, and other APIs of this exported module.

ComboboxProps

items

T[]

The options of the select

allowCustomValue

boolean

Whether to allow custom values or free values in the input

autoFocus

boolean

Whether to autofocus the input on mount

closeOnSelect

boolean

Whether to close the combobox when an item is selected.

defaultValue

string[]

dir

'ltr' | 'rtl'

The document's text/writing direction.

disabled

boolean

Whether the combobox is disabled

form

string

The associate form of the combobox.

getRootNode

() => ShadowRoot | Node | Document

A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

highlightedValue

string

The active item's id. Used to set the `aria-activedescendant` attribute

id

string

The unique identifier of the machine.

ids

Partial<{ root: string label: string control: string input: string content: 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.

inputBehavior

'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 current value of the combobox's input

invalid

boolean

Whether the combobox is required

isItemDisabled

(item: T) => boolean

Whether the item is disabled

itemToString

(item: T) => string

The label of the item

itemToValue

(item: T) => string

The value of the item

loop

boolean

Whether to loop the keyboard navigation through the items

multiple

boolean

Whether to allow multiple selection

name

string

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

onFocusOutside

(event: FocusOutsideEvent) => void

Function called when the focus is moved outside the combobox

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 combobox

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 combobox

onValueChange

(details: ValueChangeDetails<T>) => void

Function called when a new item is selected

openOnClick

boolean

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

placeholder

string

The placeholder text of the combobox's input

positioning

PositioningOptions

The positioning options to dynamically position the menu

readOnly

boolean

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

selectionBehavior

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

selectOnBlur

boolean

Whether to select the higlighted item on interaction outside the combobox

translations

IntlTranslations

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

value

string[]

The keys of the selected items

ComboboxContext

clearTriggerProps

WithoutRef< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> >

clearValue

(value?: string | undefined) => void

Function to clear the value of the combobox

close

() => void

Function to close the combobox

contentProps

WithoutRef<HTMLAttributes<HTMLElement>>

controlProps

WithoutRef<HTMLAttributes<HTMLElement>>

focus

() => void

Function to focus on the combobox input

getItemGroupLabelProps

(props: ItemGroupLabelProps) => WithoutRef<HTMLAttributes<HTMLElement>>

getItemGroupProps

(props: ItemGroupProps) => WithoutRef<HTMLAttributes<HTMLElement>>

getItemIndicatorProps

(props: ItemProps) => WithoutRef<HTMLAttributes<HTMLElement>>

getItemProps

(props: ItemProps) => WithoutRef<HTMLAttributes<HTMLElement>>

getItemState

(props: ItemProps) => ItemState

Returns the state of a combobox item

getItemTextProps

(props: ItemProps) => WithoutRef<HTMLAttributes<HTMLElement>>

hasSelectedItems

boolean

Whether there's a selected item

highlightValue

(value: string) => void

The value of the combobox input

inputProps

WithoutRef< DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> >

inputValue

string

The value of the combobox input

isFocused

boolean

Whether the combobox is focused

isInputValueEmpty

boolean

Whether the combobox input value is empty

isOpen

boolean

Whether the combobox is open

labelProps

WithoutRef< DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> >

open

() => void

Function to open the combobox

positionerProps

WithoutRef<HTMLAttributes<HTMLElement>>

rootProps

WithoutRef<HTMLAttributes<HTMLElement>>

selectedItems

T[]

The selected items

selectValue

(value: string) => void

Function to select a value

setCollection

(collection: Collection<T>) => void

Function to set the collection of items

setInputValue

(value: string) => void

Function to set the input value of the combobox

setValue

(value: string[]) => void

Function to set the value of the combobox

triggerProps

WithoutRef< DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> >

value

string[]

The selected item keys

valueAsString

string

The string representation of the selected items

highlightedItem

T

The highlighted item

highlightedValue

string

The value of the highlighted item

ComboboxItemProps

item

any

ComboboxContentProps

lazyMount

boolean

Whether to enable lazy mounting. Defaults to `false`.

onExitComplete

() => void

present

boolean

unmountOnExit

boolean

Whether to unmount on exit. Defaults to `false`.

ComboboxItemGroupProps

id

string

ComboboxItemGroupLabelProps

htmlFor

string