//
Autocomplete input and command palette with a list of suggestions.
bun add xiod-ui1import {2 Combobox,3 ComboboxChip,4 ComboboxChips,5 ComboboxChipsInput,6 ComboboxClear,7 ComboboxCollection,8 ComboboxEmpty,9 ComboboxGroup,10 ComboboxGroupLabel,11 ComboboxInput,12 ComboboxItem,13 ComboboxList,14 ComboboxPopup,15 ComboboxRow,16 ComboboxSeparator,17 ComboboxStatus,18 ComboboxTrigger,19 ComboboxValue20} from "xiod-ui/combobox";1<Combobox>2 <ComboboxChipsInput />3 <ComboboxInput />4 <ComboboxTrigger />5 <ComboboxPopup>6 <ComboboxEmpty />7 <ComboboxGroupLabel />8 <ComboboxGroup>9 <ComboboxItem />10 </ComboboxGroup>11 <ComboboxList>12 <ComboboxItem />13 </ComboboxList>14 <ComboboxChip />15 <ComboboxChips />16 <ComboboxClear />17 <ComboboxCollection />18 <ComboboxRow />19 <ComboboxSeparator />20 <ComboboxStatus />21 <ComboboxValue />22 </ComboboxPopup>23</Combobox>| Prop | Type | Default | Description |
|---|---|---|---|
form | string| undefined | - | Identifies the form that owns the internal input. Useful when the combobox is rendered outside the form. |
filter | ((item: Item, query: string, itemToString?: ((item: Item) => string)| undefined) => boolean)| null| undefined | - | 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. |
id | string| undefined | - | The id of the component. |
grid | boolean| undefined | false | Whether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows. |
inline | boolean| undefined | false | 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. |
disabled | boolean| undefined | false | Whether the component should ignore user interaction. |
name | string| undefined | - | Identifies the field when a form is submitted. |
readOnly | boolean| undefined | false | Whether the user should be unable to choose a different option from the popup. |
required | boolean| undefined | false | Whether the user must choose a value before submitting a form. |
modal | boolean| undefined | false | 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. |
open | boolean| undefined | - | Whether the popup is currently open. Use when controlled. |
defaultOpen | boolean| undefined | false | Whether the popup is initially open. To render a controlled popup, use the `open` prop instead. |
onOpenChangeComplete | ((open: boolean) => void)| undefined | - | Event handler called after any animations complete when the popup is opened or closed. |
loopFocus | boolean| undefined | true | 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>. |
inputRef | Ref<HTMLInputElement>| undefined | - | A ref to the hidden input element. |
openOnInputClick | boolean| undefined | true | Whether the popup opens when clicking the input. |
inputValue | string| number| readonly string[]| undefined | - | The input value of the combobox. Use when controlled. |
defaultInputValue | string| number| readonly string[]| undefined | - | The uncontrolled input value when initially rendered. To render a controlled input, use the `inputValue` prop instead. |
items | readonly any[]| readonly Group<any>[]| ComboboxItemCollection<Item, Value>| undefined | - | 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. |
filteredItems | readonly Item[]| readonly Group<Item>[]| undefined | - | 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. |
virtualized | boolean| undefined | false | Whether the items are being externally virtualized. |
limit | number| undefined | -1 | The maximum number of items to display in the list. |
locale | LocalesArgument | - | The locale to use for string comparison. Defaults to the user's runtime locale. |
multiple | boolean| undefined | false | Whether multiple items can be selected. |
autoComplete | string| undefined | - | Provides a hint to the browser for autofill. @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/autocomplete |
autoHighlight | boolean| undefined | false | Whether the first matching item is highlighted automatically while filtering. |
highlightItemOnHover | boolean| undefined | true | Whether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state. |
itemToStringLabel | ((itemValue: Value) => string)| undefined | - | 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. |
itemToStringValue | ((itemValue: Value) => string)| undefined | - | When the item values are objects (`<Combobox.Item value={object}>`), this function converts the object value to a string representation for form submission. If the shape of the object is `{ value, label }`, the value will be used automatically without needing to specify this prop. With a `createItems()` collection, this receives the derived value. |
isItemEqualToValue | ((itemValue: Value, value: Value) => boolean)| undefined | - | Custom comparison logic used to determine if a combobox item value matches the current selected value. Useful when item values are objects without matching referentially. With a `createItems()` collection, both arguments are derived values. Defaults to `Object.is` comparison. |
defaultValue | ComboboxValueType<Value, Multiple>| null| undefined | - | The uncontrolled selected value of the combobox when it's initially rendered. To render a controlled combobox, use the `value` prop instead. |
actionsRef | RefObject<Actions| null>| undefined | - | A ref to imperative actions. - `unmount`: Manually unmounts the combobox. Call this after any externally controlled closing animation finishes. |
onOpenChange | ((open: boolean, eventDetails: ChangeEventDetails) => void)| undefined | - | Event handler called when the popup is opened or closed. |
onInputValueChange | ((inputValue: string, eventDetails: ChangeEventDetails) => void)| undefined | - | Event handler called when the input value changes. |
onItemHighlighted | ((highlightedValue: Value| undefined, eventDetails: HighlightEventDetails) => void)| undefined | - | Callback fired when an item is highlighted or unhighlighted. Receives the highlighted item value (or `undefined` if no item is highlighted) and event details with a `reason` property describing why the highlight changed. The `reason` can be: - `'keyboard'`: the highlight changed due to keyboard navigation. - `'pointer'`: the highlight changed due to pointer hovering. - `'none'`: the highlight changed programmatically. |
value | ComboboxValueType<Value, Multiple>| null| undefined | - | The selected value of the combobox. Use when controlled. |
onValueChange | ((value: ComboboxValueType<Value, Multiple>| (Multiple extends true ? never : null), eventDetails: ChangeEventDetails) => void)| undefined | - | Event handler called when the selected value of the combobox changes. |
| Prop | Type | Default | Description |
|---|---|---|---|
className | string| ((state: ComboboxChipState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxChipState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxChipState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
removeProps | ComboboxChipRemoveProps| undefined | - |
| Prop | Type | Default | Description |
|---|---|---|---|
className | string| ((state: ComboboxChipsState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxChipsState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxChipsState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
startAddon | ReactNode | - |
| Prop | Type | Default | Description |
|---|---|---|---|
style | CSSProperties| ((state: ComboboxInputState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
className | string| ((state: ComboboxInputState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxInputState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
disabled | boolean| undefined | false | Whether the component should ignore user interaction. |
size | number| "default"| "sm"| "lg"| undefined | - |
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean| undefined | false | Whether the component should ignore user interaction. |
keepMounted | boolean| undefined | false | Whether the component should remain mounted in the DOM when not visible. |
nativeButton | boolean| undefined | true | 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>`). |
className | string| ((state: ComboboxClearState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxClearState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxClearState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| Prop | Type | Default | Description |
|---|---|---|---|
className | string| ((state: ComboboxEmptyState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxEmptyState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxEmptyState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| Prop | Type | Default | Description |
|---|---|---|---|
items | readonly any[]| undefined | - | Items to be rendered within this group. When provided, child `Collection` components will use these items. |
className | string| ((state: ComboboxGroupState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxGroupState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxGroupState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| Prop | Type | Default | Description |
|---|---|---|---|
className | string| ((state: ComboboxGroupLabelState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxGroupLabelState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxGroupLabelState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| Prop | Type | Default | Description |
|---|---|---|---|
style | CSSProperties| ((state: ComboboxInputState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
className | string| ((state: ComboboxInputState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxInputState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
disabled | boolean| undefined | false | Whether the component should ignore user interaction. |
showTrigger | boolean| undefined | true | |
showClear | boolean| undefined | false | |
startAddon | ReactNode | - | |
size | number| "default"| "sm"| "lg"| undefined | - | |
triggerProps | ComboboxTriggerProps| undefined | - | |
clearProps | ComboboxClearProps| undefined | - |
| Prop | Type | Default | Description |
|---|---|---|---|
onClick | ((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void)| undefined | - | An optional click handler for the item when selected. It fires when clicking the item with the pointer, as well as when pressing `Enter` with the keyboard if the item is highlighted when the `Input` or `List` element has focus. |
index | number| undefined | - | The index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM. |
value | any | null | A unique value that identifies this item. |
disabled | boolean| undefined | false | Whether the component should ignore user interaction. |
nativeButton | boolean| undefined | true | 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>`). |
style | CSSProperties| ((state: ComboboxItemState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
className | string| ((state: ComboboxItemState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxItemState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| Prop | Type | Default | Description |
|---|---|---|---|
style | CSSProperties| ((state: ComboboxListState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
className | string| ((state: ComboboxListState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxListState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| Prop | Type | Default | Description |
|---|---|---|---|
initialFocus | boolean| RefObject<HTMLElement| null>| ((openType: InteractionType) => boolean| void| HTMLElement| null)| undefined | - | Determines the element to focus when the popup is opened. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (first tabbable element or popup). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing. |
finalFocus | boolean| RefObject<HTMLElement| null>| ((closeType: InteractionType) => boolean| void| HTMLElement| null)| undefined | - | Determines the element to focus when the popup is closed. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (trigger or previously focused element). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing. |
className | string| ((state: ComboboxPopupState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxPopupState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxPopupState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
align | Align| undefined | start | |
sideOffset | number| OffsetFunction| undefined | 4 | |
alignOffset | number| OffsetFunction| undefined | - | |
side | Side| undefined | bottom | |
anchor | Element| VirtualElement| RefObject<Element| null>| (() => Element| VirtualElement| null)| null| undefined | - |
| Prop | Type | Default | Description |
|---|---|---|---|
className | string| ((state: ComboboxRowState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxRowState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxRowState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | Orientation| undefined | 'horizontal' | The orientation of the separator. |
className | string| ((state: ComboboxSeparatorState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxSeparatorState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxSeparatorState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| Prop | Type | Default | Description |
|---|---|---|---|
className | string| ((state: ComboboxStatusState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxStatusState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxStatusState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean| undefined | false | Whether the component should ignore user interaction. |
nativeButton | boolean| undefined | true | 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>`). |
className | string| ((state: ComboboxTriggerState) => string| undefined)| undefined | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ReactElement<unknown, string| JSXElementConstructor<any>>| ComponentRenderFn<HTMLProps, ComboboxTriggerState>| undefined | - | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | CSSProperties| ((state: ComboboxTriggerState) => CSSProperties| undefined)| undefined | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode| ((selectedValue: any) => 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. |
placeholder | 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`. |