XiodUI
HomeDocs
OverviewComponentsThemes & ColorsChangelog
⌘ K

Components

  • Accordion
  • Agent Steps
    New
  • Alert
  • Alert Dialog
  • Aspect Ratio
    New
  • Autocomplete
  • Avatar
  • Badge
  • Breadcrumb
  • Button
    Updated
  • Button Group
    New
  • Button Split
    New
  • Calendar
    New
  • Card
  • Carousel
    New
  • Checkbox
  • Circular Progress
    New
  • Collapsible
  • Color Picker
    New
  • Combobox
  • Command
  • Context Menu
    New
  • Copy To Clipboard
    New
  • Corner Badge
    New
  • Dashboard Grid
    New
  • Date Picker
    New
  • Dialog
  • Dot Matrix
    New
  • Draggable
    New
  • Drawer
    New
  • Empty
  • Field
  • Fieldset
  • File Upload
    New
  • Form
  • Frame
  • Gauge
    New
  • Grid
    New
  • Group
  • Input
  • Input Group
  • Input OTP
    New
  • Input Payment
    New
  • Input Phone
    New
  • Input Sensitive
    New
  • Kbd
  • Kinetic Click
    New
  • Label
  • List Box
    New
  • Loader
  • Marker
    New
  • Menu
  • Menubar
  • Message
    New
  • Meter
  • Morphic Toast
    New
  • Navigation Menu
  • Number Field
  • Option Picker
    New
  • Orb
    New
  • Pagination
  • Popover
  • Preview Card
  • Progress
  • Radio
  • Resizable
    New
  • Ruler Picker
    New
  • Scroll Area
  • Scroll Bar
    New
  • Select
  • Separator
  • Sidebar
  • Skeleton
  • Slider
    Updated
  • Sortable
    New
  • Switch
    Updated
  • Table
  • Tabs
  • Text
    New
  • Textarea
  • Timeline
    New
  • Toast
  • Toggle
  • Toggle Group
  • Toolbar
  • Tooltip
    Updated
  • Waveform
    New
  • Wheel Picker
    New
/
/

Loading...

Preview Skeleton

Installation Skeleton

Usage Skeleton

API Reference Skeleton

Sponsors

Support the development of XiodUI and help us build the best component library on Earth.

+++
Sponsor on GitHub

Autocomplete

Previous: Aspect RatioNext: Avatar

A text input with suggestions.

Preview

Loading Preview...

Installation

bun add xiod-ui

Usage

Imports

1import {2  Autocomplete,3  AutocompleteClear,4  AutocompleteCollection,5  AutocompleteEmpty,6  AutocompleteGroup,7  AutocompleteGroupLabel,8  AutocompleteInput,9  AutocompleteItem,10  AutocompleteList,11  AutocompletePopup,12  AutocompleteRow,13  AutocompleteSeparator,14  AutocompleteStatus,15  AutocompleteTrigger,16  AutocompleteValue17} from "xiod-ui/autocomplete";

Anatomy

1<Autocomplete>2  <AutocompleteInput />3  <AutocompleteTrigger />4  <AutocompletePopup>5    <AutocompleteEmpty />6    <AutocompleteGroupLabel />7    <AutocompleteGroup>8      <AutocompleteItem />9    </AutocompleteGroup>10    <AutocompleteList>11      <AutocompleteItem />12    </AutocompleteList>13    <AutocompleteClear />14    <AutocompleteCollection />15    <AutocompleteRow />16    <AutocompleteSeparator />17    <AutocompleteStatus />18    <AutocompleteValue />19  </AutocompletePopup>20</Autocomplete>

API Reference

Detailed documentation of properties and options.

Autocomplete

PropTypeDefaultDescription
form
string
|undefined
-Identifies the form that owns the internal input. Useful when the autocomplete is rendered outside the form.
filter
((item: unknown, query: string, itemToString?: ((item: unknown) => string)
|undefined) => boolean)
|null
|undefined
-Filter function used to match items against the input query.
defaultValue
string
|number
|readonly string[]
|undefined
-The uncontrolled input value of the autocomplete when it's initially rendered. To render a controlled autocomplete, use the `value` prop instead.
id
string
|undefined
-The id of the component.
grid
boolean
|undefined
falseWhether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows.
inline
boolean
|undefined
falseWhether 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: `<Autocomplete.Root inline open>`
disabled
boolean
|undefined
falseWhether the component should ignore user interaction.
name
string
|undefined
-Identifies the field when a form is submitted.
readOnly
boolean
|undefined
falseWhether the user should be unable to choose a different option from the popup.
required
boolean
|undefined
falseWhether the user must choose a value before submitting a form.
value
string
|number
|readonly string[]
|undefined
-The input value of the autocomplete. Use when controlled.
onValueChange
((value: string, eventDetails: AutocompleteRootChangeEventDetails) => void)
|undefined
-Event handler called when the input value of the autocomplete changes.
modal
boolean
|undefined
falseDetermines 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.
onOpenChange
((open: boolean, eventDetails: AutocompleteRootChangeEventDetails) => void)
|undefined
-Event handler called when the popup is opened or closed.
actionsRef
RefObject<AutocompleteRootActions
|null>
|undefined
-A ref to imperative actions. - `unmount`: Manually unmounts the autocomplete. Call this after any externally controlled closing animation finishes.
open
boolean
|undefined
-Whether the popup is currently open. Use when controlled.
defaultOpen
boolean
|undefined
falseWhether 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
trueWhether 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.
submitOnItemClick
boolean
|undefined
falseWhether clicking an item should submit the autocomplete's owning form. By default, clicking an item via a pointer or <kbd>Enter</kbd> key does not submit the owning form. Useful when the autocomplete is used as a single-field form search input.
autoHighlight
boolean
|"always"
|undefined
alwaysWhether the first matching item is highlighted automatically. - `true`: highlight after the user types and keep the highlight while the query changes. - `'always'`: always highlight the first item.
keepHighlight
boolean
|undefined
trueWhether the highlighted item should be preserved when the pointer leaves the list.
highlightItemOnHover
boolean
|undefined
trueWhether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state.
itemToStringValue
((itemValue: unknown) => string)
|undefined
-When the item values are objects (`<Autocomplete.Item value={object}>`), this function converts the object value to a string representation for both display in the input and form submission. If the shape of the object is `{ value, label }`, the label will be used automatically without needing to specify this prop.
onItemHighlighted
((highlightedValue: unknown, 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.
openOnInputClick
boolean
|undefined
falseWhether the popup opens when clicking the input.
filteredItems
readonly unknown[]
|readonly Group<unknown>[]
|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. Nullish entries are not supported, as in `items`. Use when you want to control filtering logic externally with the `useFilter()` hook.
virtualized
boolean
|undefined
falseWhether the items are being externally virtualized.
limit
number
|undefined
-1The 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.
mode
"none"
|"list"
|"inline"
|"both"
|undefined
'list'Controls how the autocomplete behaves with respect to list filtering and inline autocompletion. - `list` (default): items are dynamically filtered based on the input value. The input value does not change based on the active item. - `both`: items are dynamically filtered based on the input value, which will temporarily change based on the active item (inline autocompletion). - `inline`: items are static (not filtered), and the input value will temporarily change based on the active item (inline autocompletion). - `none`: items are static (not filtered), and the input value will not change based on the active item.
itemsReq
readonly { items: readonly any[]; }[]
-The items to be displayed in the list. Can be either a flat array of items or an array of groups with items. Nullish entries are not supported: remove them from the data before passing it.

AutocompleteClear

PropTypeDefaultDescription
disabled
boolean
|undefined
falseWhether the component should ignore user interaction.
keepMounted
boolean
|undefined
falseWhether the component should remain mounted in the DOM when not visible.
nativeButton
boolean
|undefined
trueWhether 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.

AutocompleteEmpty

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

AutocompleteGroup

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

AutocompleteGroupLabel

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

AutocompleteInput

PropTypeDefaultDescription
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
falseWhether the component should ignore user interaction.
showTrigger
boolean
|undefined
false
showClear
boolean
|undefined
false
startAddon
ReactNode
-
size
number
|"default"
|"sm"
|"lg"
|undefined
-
triggerProps
AutocompleteTriggerProps
|undefined
-
clearProps
ComboboxClearProps
|undefined
-

AutocompleteItem

PropTypeDefaultDescription
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
nullA unique value that identifies this item.
disabled
boolean
|undefined
falseWhether the component should ignore user interaction.
nativeButton
boolean
|undefined
trueWhether 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: AutocompleteItemState) => 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: AutocompleteItemState) => 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, AutocompleteItemState>
|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.

AutocompleteList

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

AutocompletePopup

PropTypeDefaultDescription
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
-

AutocompleteRow

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

AutocompleteSeparator

PropTypeDefaultDescription
orientation
Orientation
|undefined
'horizontal'The orientation of the separator.
className
string
|((state: AutocompleteSeparatorState) => 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, AutocompleteSeparatorState>
|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: AutocompleteSeparatorState) => CSSProperties
|undefined)
|undefined
-Style applied to the element, or a function that returns a style object based on the component's state.

AutocompleteStatus

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

AutocompleteTrigger

PropTypeDefaultDescription
disabled
boolean
|undefined
falseWhether the component should ignore user interaction.
nativeButton
boolean
|undefined
trueWhether 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: AutocompleteTriggerState) => 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, AutocompleteTriggerState>
|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: AutocompleteTriggerState) => CSSProperties
|undefined)
|undefined
-Style applied to the element, or a function that returns a style object based on the component's state.
Aspect RatioAvatar