Introducing PrimeReact v11-alpha 🎉Discover Now

AutoComplete

An unstyled autocomplete input component with real-time search, keyboard navigation, and popup positioning.

Build fully custom autocomplete inputs with complete control over layout and styling.

basic-demo

Pre-styled Versions

Choose a pre-styled library to use AutoComplete with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Compound component API with sub-components: Root, Input, Trigger, Indicator, Clear, Portal, Positioner, Popup, List, Option, OptionIndicator, Arrow, Header, Footer, Empty, Value
  • Real-time search via onComplete callback with configurable delay and minimum length
  • Force selection mode that clears unmatched input on blur
  • Option grouping with optionGroupLabel and optionGroupChildren
  • Built-in clear button and trigger toggle support

Usage#

import { AutoComplete } from 'primereact/autocomplete';
<AutoComplete.Root>
    <AutoComplete.Input />
    <AutoComplete.Trigger>
        <AutoComplete.Indicator />
    </AutoComplete.Trigger>
    <AutoComplete.Clear />
    <AutoComplete.Portal>
        <AutoComplete.Positioner>
            <AutoComplete.Popup>
                <AutoComplete.Header />
                <AutoComplete.List>
                    <AutoComplete.Option>
                        <AutoComplete.OptionIndicator />
                    </AutoComplete.Option>
                </AutoComplete.List>
                <AutoComplete.Empty />
                <AutoComplete.Footer />
            </AutoComplete.Popup>
        </AutoComplete.Positioner>
    </AutoComplete.Portal>
</AutoComplete.Root>

Behavior#

Motion Animation#

<AutoComplete.Popup motionProps={{ name: 'p-autocomplete' }}>...</AutoComplete.Popup>

See Motion for animation phases, CSS variables, and hide strategies.

Polymorphic Rendering#

Use as on any sub-component to change the rendered HTML element.

<AutoComplete.Input as={CustomInput} />
<AutoComplete.Trigger as="div">...</AutoComplete.Trigger>

Render Function Children#

AutoComplete.List accepts a render function as children, providing access to the component instance for custom option rendering.

<AutoComplete.List>
    {(instance) =>
        instance.options?.map((option, index) => (
            <AutoComplete.Option key={index} index={index}>
                {instance.listbox?.getOptionLabel(option)}
            </AutoComplete.Option>
        ))
    }
</AutoComplete.List>

Pass Through#

Some parts may not be visible in the preview depending on the component's current state.

Loading...
/* Select a part to see its CSS selector for custom styling */

API#

AutoCompleteRoot#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteRootInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteRootInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteRootInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteRootPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteRootInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
valueunknown
The current selected value of the autocomplete.
defaultValueunknown
The default selected value when used in uncontrolled mode.
inputValuestring
The current input text value (controlled).
defaultInputValuestring
The default input text value when used in uncontrolled mode.
openboolean
Controlled open state of the input tags overlay.
defaultOpenboolean
Default open state for uncontrolled mode.
optionsunknown[]
An array of options to display.
optionKeystring
Unique key for each option.
optionLabelstring
Label field for each option.
optionValuestring
Value field for each option.
optionDisabledstring
Field to check if an option is disabled.
optionGroupLabelstring
Label field for option groups.
optionGroupChildrenstring
Field that contains the children options in a group.
localestring
The locale to use for localization.
multipleboolean
When present, allows selecting multiple options.
metaKeySelectionboolean
When enabled, requires holding the meta key to select/deselect.
autoOptionFocusboolean
When enabled, the focused option is automatically highlighted.
selectOnFocusboolean
When enabled, the focused option is automatically selected.
focusOnHoverboolean
When enabled, the focused option changes on hover.
minLengthnumber
Minimum number of characters to initiate a search.
delaynumber
Delay between keystrokes to wait before sending a query.
forceSelectionboolean
When present, it specifies that an input field must be filled out before submitting the form.
tabIndexnumber
Index of the element in tabbing order.
invalidboolean
When present, it specifies that the component is in an invalid state.
namestring
Name of the input element.
requiredboolean
When present, it specifies that an input field is required.
closeOnEscapeboolean
When enabled, the overlay closes when Escape key is pressed.
autoFocusboolean
When enabled, the overlay receives focus automatically when opened.
trappedboolean
When enabled, focus is trapped within the overlay.
onOpenChange(event: useAutoCompleteOpenChangeEvent) => void
Callback to invoke when the open state changes.
disabledbooleanfalse
When present, it specifies that the element should be disabled.
onValueChange(event: AutoCompleteValueChangeEvent) => void
Callback fired when the autocomplete's input value is changed.
onInputValueChange(event: AutoCompleteInputValueChangeEvent) => void
Callback fired when the autocomplete's input value is changed.
onComplete(event: AutoCompleteCompleteEvent) => void
Callback fired when the autocomplete's search is completed.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"autocomplete"
data-part"root"

Defines passthrough(pt) options of AutoComplete component.

labeltypedescription
rootAutoCompleteRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.
triggerAutoCompleteRootPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the trigger's DOM element.
pcInputTextAutoCompleteRootPassThroughType<HTMLAttributes<HTMLInputElement>>Used to pass attributes to the pcInputText's DOM element.
valueAutoCompleteRootPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the value's DOM element (non-editable mode).
positionerAutoCompleteRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the positioner's DOM element.
popupAutoCompleteRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the popup's DOM element.
listAutoCompleteRootPassThroughType<HTMLAttributes<HTMLUListElement>>Used to pass attributes to the list's DOM element.
optionAutoCompleteRootPassThroughType<HTMLAttributes<HTMLLIElement>>Used to pass attributes to the option's DOM element.
clearIconAutoCompleteRootPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the clearIcon's DOM element.
selectionAutoCompleteRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the selection's DOM element.
headerAutoCompleteRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the header's DOM element.
footerAutoCompleteRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the footer's DOM element.
emptyAutoCompleteRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the empty's DOM element.

AutoCompleteInput#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteInputInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteInputInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteInputInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteInputPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteInputInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"autocomplete"
data-part"input"

Defines passthrough(pt) options of AutoCompleteInput component.

labeltypedescription
rootAutoCompleteInputPassThroughType<HTMLAttributes<HTMLInputElement>>Used to pass attributes to the root's DOM element.

AutoCompleteTrigger#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteTriggerInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteTriggerInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteTriggerInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteTriggerPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteTriggerInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"autocomplete"
data-part"trigger"
data-positioner-openPresent when popup is open

Defines passthrough(pt) options of AutoCompleteTrigger component.

labeltypedescription
rootAutoCompleteTriggerPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

AutoCompleteIndicator#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteIndicatorInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteIndicatorInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteIndicatorInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteIndicatorPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteIndicatorInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
match"always" | "open" | "closed"
Determines the visibility of the indicator based on the state of the autocomplete. - "open": Indicator is visible when the dropdown is open. - "closed": Indicator is visible when the dropdown is closed. - "always": Indicator is always visible.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"autocomplete"
data-part"indicator"
data-openPresent when popup is open
data-closedPresent when popup is closed

Defines passthrough(pt) options of AutoCompleteIndicator component.

labeltypedescription
rootAutoCompleteIndicatorPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the root's DOM element.

AutoCompleteClear#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteClearInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteClearInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteClearInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteClearPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteClearInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"autocomplete"
data-part"clear"

Defines passthrough(pt) options of AutoCompleteClear component.

labeltypedescription
rootAutoCompleteClearPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the root's DOM element.

AutoCompletePortal#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
style(CSSProperties | ((instance?: PortalInstance) => CSSProperties)) & (CSSProperties | ((instance?: AutoCompletePortalInstance) => CSSProperties))
The style to apply to the component.
className(string | ((instance?: PortalInstance) => string)) & (string | ((instance?: AutoCompletePortalInstance) => string))
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceBaseInstance<SafeRecord<PortalProps>, unknown, HTMLElement> & { props: SafeRecord<SafeRecord<PortalProps>>; attrs: Omit<SafeRecord<SafeRecord<PortalProps>>, string | number | symbol> & Record<PropertyKey, unknown> } & { state: SafeRecord; $computedSetup: SafeRecord } & PortalExposes & Record<PropertyKey, unknown> & useComponentPTReturnType & useComponentStyleReturnType & BaseInstance<SafeRecord<AutoCompletePortalProps>, unknown, HTMLElement> & { props: SafeRecord<SafeRecord<AutoCompletePortalProps>>; attrs: Omit<SafeRecord<SafeRecord<AutoCompletePortalProps>>, string | number | symbol> & Record<PropertyKey, unknown> } & { state: SafeRecord; $computedSetup: SafeRecord } & AutoCompletePortalExposes
The instance to pass to the component.
ptPortalPassThrough & Record<PropertyKey, unknown> & AutoCompletePortalPassThrough
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: PortalInstance) => ReactNode & (instance: AutoCompletePortalInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
onMounted() => void
Callback function to invoke when the portal is mounted.
onUnmounted() => void
Callback function to invoke when the portal is unmounted.
elementHTMLElement | ReactNode
The element to be rendered as the portal.
elementRefRefObject<HTMLElement>
The element reference to be rendered as the portal.
appendTostring | HTMLElement | ((instance: PortalInstance) => HTMLElement)'body'
The DOM element where the portal should be appended to.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of AutoCompletePortal component.

labeltypedescription
rootAutoCompletePortalPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

AutoCompletePositioner#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompletePositionerInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompletePositionerInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompletePositionerInstance
The instance to pass to the component.
ptSafeRecord<AutoCompletePositionerPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompletePositionerInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
sideSideType
The side of the positioner.
alignAlignType
The align of the positioner.
sideOffsetnumber
The side offset of the positioner.
alignOffsetnumber
The align offset of the positioner.
flipboolean
Whether to flip the positioner.
shiftboolean
Whether to shift the positioner.
hideWhenDetachedboolean
Whether to hide the positioner when detached.
strategy"fixed" | "absolute"'fixed'
The positioning strategy.
boundaryHTMLElement
The boundary element that constrains the positioner placement. Used in JS fallback mode only; CSS Anchor mode uses the containing block.
anchorHTMLElement
The anchor element.
contentHTMLDivElement
The content element.
arrowHTMLDivElement
The arrow element.
autoZIndexbooleantrue
Whether to automatically manage layering.
baseZIndexnumber0
Base zIndex value to use in layering.
onPlacementChange(placement: { side: SideType; align: AlignType }) => void
Callback invoked when the actual placement changes due to flip or shift.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-side"top" | "bottom" | "left" | "right" — placement
data-align"start" | "center" | "end" — alignment

CSS Custom Properties

The positioner element exposes CSS custom properties for layout and transform control.

CSS VariableDescription
--available-heightAvailable vertical space in pixels
--available-widthAvailable horizontal space in pixels
--transform-originComputed transform origin for animations
--positioner-anchor-widthWidth of the anchor/trigger element

Defines passthrough(pt) options of AutoCompletePositioner component.

labeltypedescription
rootAutoCompletePositionerPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

AutoCompletePopup#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompletePopupInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompletePopupInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompletePopupInstance
The instance to pass to the component.
ptSafeRecord<AutoCompletePopupPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompletePopupInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
motionPropsuseMotionProps
Used to apply motion to the popup element. It accepts the same properties as useMotion hook.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"autocomplete"
data-part"popup"
data-openPresent when popup is open

Defines passthrough(pt) options of AutoCompletePopup component.

labeltypedescription
rootAutoCompletePopupPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

AutoCompleteList#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteListInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteListInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteListInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteListPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteListInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"autocomplete"
data-part"list"

Defines passthrough(pt) options of AutoCompleteList component.

labeltypedescription
rootAutoCompleteListPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

AutoCompleteOption#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteOptionInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteOptionInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteOptionInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteOptionPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteOptionInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
optionunknown
The option data.
indexnumber
The index of the option.
selectedboolean
Whether the option is selected.
focusedboolean
Whether the option is focused.
disabledboolean
Whether the option is disabled.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-selectedPresent when selected
data-unselectedPresent when unselected
data-focusedPresent when focused
data-disabledPresent when disabled

Defines passthrough(pt) options of AutoCompleteOption component.

labeltypedescription
rootAutoCompleteOptionPassThroughType<HTMLAttributes<HTMLLIElement>>Used to pass attributes to the root's DOM element.

AutoCompleteOptionIndicator#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteOptionIndicatorInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteOptionIndicatorInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteOptionIndicatorInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteOptionIndicatorPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteOptionIndicatorInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-selectedPresent when selected
data-unselectedPresent when unselected

Defines passthrough(pt) options of AutoCompleteOptionIndicator component.

labeltypedescription
rootAutoCompleteOptionIndicatorPassThroughType<HTMLAttributes<HTMLElement>>Used to pass attributes to the root's DOM element.

AutoCompleteHeader#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteHeaderInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteHeaderInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteHeaderInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteHeaderPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteHeaderInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of AutoCompleteHeader component.

labeltypedescription
rootAutoCompleteHeaderPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

AutoCompleteFooter#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteFooterInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteFooterInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteFooterInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteFooterPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteFooterInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of AutoCompleteFooter component.

labeltypedescription
rootAutoCompleteFooterPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

AutoCompleteEmpty#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteEmptyInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteEmptyInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteEmptyInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteEmptyPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteEmptyInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of AutoCompleteEmpty component.

labeltypedescription
rootAutoCompleteEmptyPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

AutoCompleteArrow#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteArrowInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteArrowInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteArrowInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteArrowPassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteArrowInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-side"top" | "bottom" | "left" | "right" — placement
data-align"start" | "center" | "end" — alignment

The arrow element exposes CSS custom properties for dynamic positioning:

CSS VariableDescription
--placer-arrow-xHorizontal offset of arrow
--placer-arrow-yVertical offset of arrow
--placer-arrow-leftLeft position of arrow element
--placer-arrow-topTop position of arrow element

Defines passthrough(pt) options of AutoCompleteArrow component.

labeltypedescription
rootAutoCompleteArrowPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

AutoCompleteValue#

NameTypeDefault
refRef<unknown>
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: AutoCompleteValueInstance) => CSSProperties)
The style to apply to the component.
classNamestring | ((instance?: AutoCompleteValueInstance) => string)
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceAutoCompleteValueInstance
The instance to pass to the component.
ptSafeRecord<AutoCompleteValuePassThrough>
The pass-through props to pass to the component.
ptOptionsPassThroughOptions
The pass-through options to pass to the component.
unstyledboolean
Whether the component should be rendered without classes.
dtunknown
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
The styles to use for the component.
render(instance: AutoCompleteValueInstance) => ReactNode
The render function to render the component with instance access.
childrenany
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
placeholderstring
Placeholder text to display when no option is selected.
[key: string]any
pt-{optionName}-*-
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of AutoCompleteValue component.

labeltypedescription
rootAutoCompleteValuePassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

AutoComplete.Root uses a combobox pattern. The input has role="combobox" with aria-autocomplete, aria-haspopup and aria-expanded attributes. The relation between the input and the popup is created with aria-controls and aria-activedescendant attribute is used to instruct screen reader which option to read during keyboard navigation within the popup list. Options have role="option" with aria-selected to indicate the current selection. The clear button has an aria-label for screen reader accessibility. Provide an accessible name with aria-label, aria-labelledby, or an associated label element.

Keyboard Support#

KeyFunction
tabMoves focus to the autocomplete element.
any printable characterOpens the popup and displays matching suggestions.
enterSelects the focused option and closes the popup.
escapeCloses the popup.
arrow downOpens the popup or moves focus to the next option.
arrow upOpens the popup or moves focus to the previous option.
arrow leftRemoves the visual focus from the current option and moves input cursor.
arrow rightRemoves the visual focus from the current option and moves input cursor.
homeMoves focus to the first option.
endMoves focus to the last option.
pageUpJumps visual focus to the first option.
pageDownJumps visual focus to the last option.