Skip to Content
Puzzle

Autocomplete

Search options, select multiple values, or accept custom text.

Import

import { Autocomplete } from "@puzzle-ui/ui";

Controlled selection

Options pair a display label with a typed value. Clearing a controlled single selection produces undefined, not null.

390 × 450

Multiple values and custom text

multiple uses an array. freeSolo permits text not present in the options; Enter commits it. Use maxSelected to limit selections.

390 × 500

Validation and loading

390 × 400

API

Selection and input

V is T, or T | string when freeSolo is enabled.

PropTypeDefaultDescription
optionsreadonly AutocompleteOption<T>[]RequiredSearchable options.
value, defaultValueV | undefined, or readonly V[] in multiple mode-Controlled/initial selection.
onChange(value: V | undefined) => void, or (values: V[]) => void-Selection callback.
multiple, freeSolobooleanfalseMultiple selection or custom text.
label, description, errorReactNode-Accessible field content.
disabled, required, readOnlybooleanfalseInput state.
inputValue, defaultInputValuestring-Controlled/initial search text.
onInputChange(text, reason) => void-Reasons: "input", "reset", "clear", "select".
name, formstring-Native form association.
serializeValue(value: V) => stringBuilt-in serializationHidden-input value serialization.
isOptionEqualToValue(option: AutocompleteOption<T>, value: V) => booleanBuilt-in equalityMatch object-valued selections.
filterOptions(options, inputValue) => optionsBuilt-in filterCustom search filtering.
renderOption(option, state) => ReactNodeOption label/descriptionCustom non-interactive option content.
maxSelected, maxOptionsnumber-Selection and visible-option limits.
filterSelectedOptionsboolean-Hide selected options.
clearablebooleantrueShow clear control.
clearLabel, removeOptionLabelstring"Clear selection", "Remove"Accessible button text.
clearOnBlurbooleanDepends on freeSoloReset uncommitted input on blur.
clearOnEscapebooleanfalseAllow Escape to clear.
PropTypeDefaultDescription
open, defaultOpenbooleanfalseControlled/initial menu state.
onOpenChange(open: boolean) => void-Menu state changes.
openOnFocus, autoHighlightbooleanfalseOpen on focus or highlight the first option.
closeOnSelectbooleanSingle: true; multiple: falseDismiss after choosing.
loadingbooleanfalseLoading state.
loadingText, noOptionsTextReactNode"Loading options...", "No options found"Menu feedback.
requiredMessagestring"Please select an option."Required validation message.
position"top" | "right" | "bottom" | "left""bottom"Preferred side.
align"start" | "center" | "end""start"Alignment.
offset, collisionPaddingnumber8Positioning distances in pixels.
matchTriggerWidthbooleantrueMenu width follows input.
menuMaxHeightstring | number"18rem"Menu height limit.
sizeResponsive "sm" | "md" | "lg""md"Input size.
fullWidthResponsive booleanfalseFill available width.
className, inputClassName, popoverClassName, menuClassName, optionClassNamestring-Scoped styling hooks.

Options support id, value, label, description, group, and disabled. Standard input attributes and refs are supported. Arrow keys navigate, Enter selects, and Escape closes. Custom renderers must not nest interactive controls inside options.

;