shadcn.io is an independent project built on shadcn/ui
On this page9 sections
An autocomplete is a text field that suggests as people type, where whatever they type is still a valid answer: a search box, a city, a tag. Picking a suggestion fills the field, and as they type, the field completes the first match with the added letters selected, so Backspace takes the completion back out.
When the answer has to be one of the options, use a Combobox. For a short, fixed list with no typing at all, a Select is simpler.
Installation
Anatomy

Usage
import { useId } from "react";
import {
Autocomplete, AutocompleteContent, AutocompleteEmpty,
AutocompleteInput, AutocompleteItem, AutocompleteList, useFilter,
useListCollection,
} from "@/components/ui/autocomplete";
import { Field, FieldLabel } from "@/components/ui/field";const AutocompleteDemo = () => {
const inputId = useId();
const { contains } = useFilter({ sensitivity: "base" });
const { collection, filter } = useListCollection({
filter: contains,
initialItems,
});
return (
<Field className="w-full max-w-64">
<FieldLabel htmlFor={inputId}>Search fruits</FieldLabel>
<Autocomplete
collection={collection}
ids={{ input: inputId }}
onInputValueChange={({ inputValue }) => filter(inputValue)}
>
<AutocompleteInput placeholder="e.g. Apple" showClear />
<AutocompleteContent>
<AutocompleteEmpty />
<AutocompleteList>
{collection.items.map((item) => (
<AutocompleteItem item={item} key={item.value}>
{item.label}
</AutocompleteItem>
))}
</AutocompleteList>
</AutocompleteContent>
</Autocomplete>
</Field>
);
};
const initialItems = [
{ label: "Apple", value: "apple" },
{ label: "Banana", value: "banana" },
{ label: "Cherry", value: "cherry" },
{ label: "Date", value: "date" },
];Accessibility
The input has role="combobox" and aria-autocomplete="both", because typing completes the first match and moving through the suggestions writes each one into the field, and focus stays in the input while aria-activedescendant reports the highlighted one. With inputBehavior set to autohighlight or none, the field only suggests and says aria-autocomplete="list". Naming the field is up to you. Inside a Field, the FieldLabel labels the input on its own, as the preview at the top shows, and outside one, give AutocompleteInput an aria-label.
- Arrow Down
- When the list is closed, opens it. In the open list, highlights the next suggestion and writes it into the field, and from the last one, goes back to the first.
- Arrow Up
- When the list is closed, opens it. In the open list, highlights the previous suggestion and writes it into the field, and from the first one, goes to the last.
- Arrow Right
- Keeps the completion in the field and moves the caret to its end.
- End
- Keeps the completion in the field and moves the caret to its end.
- Backspace
- Deletes the selected completion and leaves what you typed. Nothing completes again until you type another letter.
- Enter
- Picks the highlighted suggestion, which is the completed match while one shows, and closes the list. With nothing highlighted, the typed text stays and the form can submit.
- EscEscape
- Closes the list and puts back the text you typed.
Demos
Async
A stand-in for a movie API: each keystroke passes the text to useAsyncList, whose load waits 300 milliseconds and returns the titles that contain it. The list shows "Start typing to search." at first, "Searching..." during a request and "No results found." on a miss. Picking a title doesn't search again, because only an input-change reason updates the query.
Autohighlight
inputBehavior set to autohighlight replaces this component's inline completion, so the first match is highlighted as you type and Enter picks it, while the field keeps exactly what you typed. The arrow keys move the highlight without writing suggestions into the field. Use it where the top match is usually right and the text shouldn't change under the cursor.
Context
A size field, Small, Medium or Large, under a line that reads "Selected:" and the picked label, or None before anything is picked. AutocompleteContext hands the live state to that line through a render function, which reads valueAsString. Use it when nearby markup should follow the field and you'd rather not keep a copy of the value yourself.
Controlled
The fruit value lives in your own state, starts as banana, and the line under the field prints it. value is an array even for one choice, so the demo wraps the string going in and keeps the first entry coming out. Typed text that matches nothing never reaches value, which only holds suggestions that were picked.
Creatable
Bug, Feature and Docs to start with. Type a label that isn't there and the list offers "+ Create" with your text, and picking it turns that row into a real option marked "(new)". The demo does it with upsert, update and remove from useListCollection, keyed on a placeholder value. Use it for tags and labels, where the list suggests rather than limits.
Custom object
Three countries stored as objects with a flag, a name and a code. itemToString tells the collection that the name is the text to match and to fill in, and itemToValue that the code is the value to keep. Use this whenever the id you store and the text people read are different fields of a record.
Disabled
disabled on Autocomplete fades the fruit field and stops both typing and opening. Use it when the field waits on an earlier answer or the person can't change it, and say why next to it, since a dead field with only a placeholder looks broken.
Dynamic
The suggestions are built, not looked up: each keystroke makes three email addresses from the text so far, at gmail.com, yahoo.com and shadcn.io, and hands them to the collection's set. The collection starts empty, so there are no suggestions until the first keystroke. Use it when suggestions come from the input itself, such as email domains or the rest of a code.
Group
Nine countries under three headings, North America, Europe and Asia, from groupBy on useListCollection and the heading prop on AutocompleteGroup. Filtering runs across all of them, and a heading shows only while its group has a match. Group suggestions when people think of the category first.
Highlight
Four names, with the typed letters marked inside each suggestion by the Highlight component, which reads the live inputValue from AutocompleteContext and ignores case. A contains match can land mid-word, as "ohn" does in Bob Johnson, and the mark shows why that row is in the list.
Inline
Sea animals filtered with startsWith, so only names that begin with the typed letters stay. Type "do" and the field reads Dolphin with the rest selected, the inline completion this component does by default. The arrow keys write the highlighted animal into the field, ArrowRight or End keeps it, and Escape puts your text back. Match from the front for names and codes people type from the start.
Invalid
invalid on Autocomplete puts aria-invalid on the input, which turns the field's border red and tells screen readers the value is wrong. The demo shows no message, so pair it with a sentence under the field that says what failed, shown after a submit rather than on first view.
Limit results
Ten US cities with a limit of 5 on useListCollection, so the popup shows at most five matches at a time. The rest are still searched, and typing more letters brings a city that missed the first five into view. Limit a long catalog this way rather than slicing the array before the filter runs.
Links
Three suggestions that are links, GitHub, MDN Web Docs and React, each rendered as an <a> through render on AutocompleteItem and opened in a new tab. Enter on one follows its link, and selectionBehavior set to preserve keeps the query in the field instead of swapping in the label. Use links when the suggestions are destinations, not values to store.
Multiple
Six programming languages with multiple set, so every pick is kept, the field clears after each one and the list stays open for the next. The picks show above the field, read from selectedItems in AutocompleteContext, with "None selected" before the first. Use it for skills or tags, where one answer is rarely the whole answer.
Rehydrate
The value starts as C-3PO while the character list is still empty, and the list arrives 800 milliseconds later, the way a saved value often loads before its options. A small child component then calls syncSelectedItems from the autocomplete's context in an effect, once the options are there, so the stored value attaches to its item. Reach for it whenever the value is known before the collection.
Root provider
A Focus input button sits outside the field and focuses it when pressed. useAutocomplete creates the state, AutocompleteRootProvider shares it with the field, and the button calls focus on that same object. Use the provider when a toolbar or a shortcut elsewhere on the page has to drive the field.
Size lg
size set to lg on AutocompleteInput gives the field a fixed h-9 height, with showClear and showTrigger on. In some of this site's styles that is already the default height, so compare it with the fields around it before you use it.
Size md
md is the default, so leaving size off gives the same field, shown here with showClear and showTrigger on. Its height comes from the style rather than a fixed class, which keeps it level with the inputs around it. Use it unless a toolbar or a large search field calls for another size.
Size sm
size set to sm gives the field a fixed h-7 height, with showClear and showTrigger on, for a toolbar, a dialog or a filter row where the default would dominate. Skip it for the main search on a page, where a short field is easy to miss.
With clear button
showClear on AutocompleteInput adds a button that empties the field. It only appears while there's text, which is why it shows here, where the field starts on Apple. It's off by default, so a search can look like a plain text field, and worth adding when people often clear the field to start again.
With field
A country field with a FieldLabel, a description about shipping estimates and required on the root. UI SDK's Field ties the label and the description to the input on its own, and the label's htmlFor matches the id the root's ids gives the input. A placeholder is no substitute for the label, because it disappears as soon as someone types.
With start icon
An apple icon sits at the start of the field, an InputGroupAddon passed as a child of AutocompleteInput, and it's hidden from screen readers. The placeholder says what to search but goes away once someone types, so aria-label on AutocompleteInput names the field for screen readers.
With trigger
showTrigger adds the chevron button that opens the full list without typing, and with showClear off it's the only extra control. Both are off by default. Turn the trigger on for a short list people also browse, and leave it off for a field that should look like search.
FAQ
What's the difference between an Autocomplete and a Combobox?
An Autocomplete keeps whatever people type and only suggests: the text in the field is the answer, and picking a suggestion fills it in. A Combobox treats the list as the answer and doesn't keep text that matches nothing.
Here the Autocomplete is built on UI SDK's own Autocomplete, which keeps only the text, and this component adds the collection and the picked value. Use it for a search box, a city or a tag, and a Combobox when the value has to be one of the options.
How do I filter Autocomplete suggestions as the user types in React?
Build the suggestions with useListCollection and a matcher from useFilter, then call the filter it returns with the new text from onInputValueChange and render collection.items. Use contains to match anywhere in the label, as most demos here do, or startsWith to match from the front, as Inline does.
The match runs on each item's label, or on whatever itemToString returns, as in the Custom object demo.
How do I load Autocomplete suggestions from an API?
Use useAsyncList, which this component's file exports beside Autocomplete: pass the new text to its setFilterText, build the collection from its items, and show a loading row while it's loading, as the Async demo does. Its load function receives the text and an abort signal, so a request that a newer keystroke made stale can be dropped.
Update the text only on the input-change reason, or picking a suggestion starts another search.
How do I let users create a new option in the Autocomplete?
The field already keeps text that matches nothing, so a create row is only needed when the new text should join the list. Add one while the text is new, by calling upsert with a placeholder item labeled with that text, and turn it into a real option with update once it's picked, as the Creatable demo does.
Remove the row when the field is empty, and skip it for text that differs from an existing option only in case.
How do I get the typed text from an Autocomplete, or submit it with a form?
The typed text is the input value: read inputValue from onInputValueChange, or control it by passing inputValue yourself. value is separate and holds only suggestions that were picked, as an array, so text that matches nothing never shows up there.
For a form, set name on Autocomplete. UI SDK puts the name on the text input, so the form receives what's in the field.
Why does the Autocomplete change my text when I press the arrow keys?
This component sets inputBehavior to autocomplete, which turns on UI SDK's inline completion. Typing fills in the rest of the first match with the added letters selected, and moving the highlight with the arrow keys writes that suggestion into the field. ArrowRight or End keeps it, and Escape puts back the text you typed.
onInputValueChange still hears only what was typed, so the completion doesn't narrow your filter. With multiple, nothing completes, since the field clears after each pick.
To stop it, set inputBehavior to autohighlight, which highlights the first match as you type and leaves the text alone, as the Autohighlight demo does. Set it to none for no highlight and no completion at all.
How do I limit the number of Autocomplete suggestions?
Pass limit to useListCollection, such as 5, and the popup shows at most that many matches, as the Limit results demo does. The full list is still searched, so typing more letters reaches anything that missed the cut.
Slicing the array yourself would hide those options from the filter entirely, so let limit do it.
How do I add a clear button or a dropdown arrow to the Autocomplete?
Set showClear or showTrigger on AutocompleteInput, as the With clear button and With trigger demos do. Both are off by default, so the field looks like a plain text input.
The clear button only appears while the field has text, and the chevron opens the whole list without any typing, which helps when people want to browse.
API Reference
Autocomplete
inputValue?string
The text. Pass it to control it.
defaultInputValue?stringonInputValueChange?(details: AutocompleteInputValueChangeDetails) → void
- Type
(details: AutocompleteInputValueChangeDetails) → void- Parameters
details– { inputValue: string; reason?: AutocompleteInputValueChangeReason }- Returns
void
open?boolean
Whether it's open. Pair with onOpenChange to control it.
defaultOpen?boolean
Whether it starts open, when you don't control open.
onOpenChange?(details: AutocompleteOpenChangeDetails) → void
Called when it opens or closes.
- Type
(details: AutocompleteOpenChangeDetails) → void- Parameters
details– { open: boolean; reason?: AutocompleteOpenChangeDetailsReason }- Returns
void
value?string[]
The chosen items' values. Pass it to control them.
defaultValue?string[]
The value it starts with, when you don't control value.
onValueChange?(details: AutocompleteValueChangeDetails<T>) → void
Called when the value changes.
- Type
(details: AutocompleteValueChangeDetails<T>) → void- Parameters
details– AutocompleteValueChangeDetails<T>- Returns
void
collectionListCollection<T>
The suggestions. Filter it as the text changes, in onInputValueChange.
- Type
ListCollection<T>
allowCustomValue?boolean
Any text is allowed: kept for the other bases' markup.
closeOnSelect?boolean
- Default
true without `multiple`
disabled?boolean
Whether it's disabled.
form?string
The id of the form it submits with, when it isn't inside one.
ids?{ input?: string; control?: string }
Ids for the parts: input ties the field to a <label htmlFor>.
- Type
{ input?: string; control?: string }
inputBehavior?"autohighlight" | "autocomplete" | "none"
autohighlight highlights the first suggestion as you type, so Enter
chooses it. autocomplete completes the text inline: the field shows the
rest of the first suggestion that starts with what was typed, selected,
and arrow keys fill in the suggestion they highlight. ArrowRight or End
keeps it; Escape takes it back out. Either way the input value the app
hears stays what was typed. The type's default: none", or "autocomplete" on Autocomplete``.
- Type
"autohighlight" | "autocomplete" | "none"- Default
"autocomplete"
invalid?boolean
Whether it's invalid.
lazyMount?boolean
Kept for the other bases' markup: a closed popup leaves the page.
loopFocus?boolean
Whether arrow keys wrap from the last suggestion to the first.
multiple?boolean
Whether several items can be chosen; the text clears after each.
name?string
The name it submits with its form.
onHighlightChange?(details: AutocompleteHighlightChangeDetails<T>) → void
- Type
(details: AutocompleteHighlightChangeDetails<T>) → void- Parameters
details– AutocompleteHighlightChangeDetails<T>- Returns
void
onSelect?(details: AutocompleteSelectionDetails) → void
Runs when an item is chosen, before onValueChange.
- Type
(details: AutocompleteSelectionDetails) → void- Parameters
details– { itemValue: string; value: string[] }- Returns
void
openOnClick?boolean
Whether pressing the field opens the suggestions.
- Default
true
positioning?{ placement?: string; gutter?: number }
Where the suggestions open, as Ark names it (bottom-start) and its gap.
- Type
{ placement?: string; gutter?: number }
readOnly?booleanrequired?boolean
Whether a value is required to submit its form.
selectionBehavior?"clear" | "replace" | "preserve"
What the text becomes once an item is chosen: its label (replace),
what was typed (preserve) or nothing (clear).
- Type
"clear" | "replace" | "preserve"- Default
"replace", or "clear" with `multiple`
unmountOnExit?boolean
Whether a closed popup leaves the page. @default true.
AutocompleteRootProvider
valueAutocompleteApi<T>
What useAutocomplete returned.
- Type
AutocompleteApi<T>
lazyMount?boolean
Kept for the other bases' markup: a closed popup leaves the page.
unmountOnExit?boolean
Whether a closed popup leaves the page. @default true.
- Default
true
AutocompleteControl
<div> data-slot="autocomplete-control"
className?string
Merged with the part's classes.
AutocompleteInput
<input> data-slot="input-group"
disabled?boolean
Whether the control is disabled.
- Default
false
showClear?boolean
Whether to show the clear button.
- Default
false
showTrigger?boolean
Whether to show the trigger button.
- Default
false
size?AutocompleteInputSize
The size of the input.
- Default
"md"
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-closed?string
Present while the suggestions are closed, including while they animate out.
data-disabled?string
Present when the field is disabled, by its own prop, a field or a <fieldset>.
data-open?string
Present while the suggestions are open.
data-readonly?string
Present when the field is read-only.
data-required?string
Present when the field is required.
data-size"icon-xs"
- Default
"icon-xs"
data-variant"ghost"
- Default
"ghost"
AutocompleteTrigger
<button> data-slot="autocomplete-trigger"
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-closed?string
Present while the suggestions are closed, including while they animate out.
data-disabled?string
Present when the field is disabled, by its own prop, a field or a <fieldset>.
data-open?string
Present while the suggestions are open.
data-readonly?string
Present when the field is read-only.
data-required?string
Present when the field is required.
AutocompleteClear
<button> data-slot="autocomplete-clear"
keepMounted?boolean
Whether the clear button stays in the page while the field is empty.
- Default
false
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
data-disabled?string
Present when the field is disabled or read-only.
AutocompleteContent
<div> data-slot="autocomplete-content"
align?Align
How the popup lines up with the anchor along that side. start and end follow the reading direction. How the suggestions line up with the field along that side. UI SDK's default: start.
- Default
internal.align
alignOffset?number
Shift along the anchor, in pixels. Shift along the field, in pixels.
- Default
0
anchor?string | Anchor | null
Positions the popup against this instead of its trigger: an element, a CSS selector, a point like { x, y }, or anything with getBoundingClientRect(). It's read on every check, so it can move. A controller's open({ anchor }) wins for that open.
- Type
string | Anchor | null- Default
internal.control ?? undefined
arrowPadding?number
Space to keep between the arrow and the popup's corners, in pixels.
- Default
6
collisionPadding?number
Space to keep from the viewport edges, in pixels.
- Default
8
container?DocumentFragment | Element | null
Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
- Type
DocumentFragment | Element | null
keepMounted?boolean
Whether the suggestions stay in the page, hidden, while closed. UI SDK's default: false.
- Default
keep
side?Side
Which side of the anchor the popup opens on. Flips to the other side when there isn't room. Which side of the field the suggestions open on. UI SDK's default: bottom.
- Default
internal.side
sideOffset?number
Gap between the anchor and the popup, in pixels. Gap between the field and the suggestions, in pixels. UI SDK's default: 4.
- Default
internal.sideOffset
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-align"start" | "center" | "end"
How the suggestions line up with the field.
- Type
"start" | "center" | "end"
data-closed?string
Present while the suggestions are closed, including while they animate out.
data-empty?stringdata-ending-style?string
Present while the list animates out. Style the state you animate to.
data-has-icons?string
Present while any suggestion inside holds an icon part, so items without one can line up.
data-modality"keyboard" | "pointer"
Whether the keyboard or a pointer moves the highlight. Style a focus ring for the keyboard only.
- Type
"keyboard" | "pointer"
data-open?string
Present while the suggestions are open.
data-presentation"popover" | "sheet"
How the suggestions present this time they're open.
- Type
"popover" | "sheet"
data-side"top" | "right" | "bottom" | "left"
Where the suggestions ended up, after flipping away from edges.
- Type
"top" | "right" | "bottom" | "left"
data-starting-style?string
Present for the first frame. Style the state you animate from.
--anchor-heightstring
Height of the anchor.
--anchor-widthstring
The anchor's width.
--arrow-offsetstring
Where the anchor's center falls along the popup's edge, kept arrowPadding from the corners. Position a ::before arrow with it.
--available-heightstring
The height left between the anchor and the viewport's edge.
--available-widthstring
The width left between the anchor and the viewport's edge.
--drawer-dimstring
While it presents as a sheet: how dim the page behind is, from 0 to 1. The backdrop's opacity follows it.
--drawer-expandstring
While it presents as a sheet: 0 at the second-largest snap point and below, 1 at the largest. With one snap point, the whole travel.
--drawer-progressstring
While it presents as a sheet: how far open the sheet is, from 0 closed to 1 at its largest snap point. Never past 1.
--drawer-stackstring
While it presents as a sheet: how many sheets opened from inside this one are open above it, rising smoothly as each one opens. Push it back with it.
--sheet-backdropstring
Set it yourself: the color the page dims to while it presents as a sheet. Black at 0.2 by default.
--transform-originstring
Where the content scales from, on its trigger's side.
AutocompleteGroup
<div> data-slot="autocomplete-group"
heading?string | React.ReactNode
The heading of the group.
- Type
string | React.ReactNode
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
AutocompleteGroupLabel
<div> data-slot="autocomplete-group-label"
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
AutocompleteItem
<div> data-slot="autocomplete-item"
disabled?boolean
Keeps the suggestion from being chosen. Sets data-disabled and aria-disabled.
- Default
(known && collection.getItemDisabled(item))
index?number
The suggestion's position among all visible ones, for virtualized lists that render only some. Sets aria-posinset and aria-setsize.
item?unknown
The collection's item it shows: its value, text and disabled state come from there.
keywords?string[]
More words filtering matches.
label?string
The text the field gets and filtering matches, when the content isn't plain text. Not the accessible name: use aria-label for that.
persistFocus?boolean
Kept for the other bases' markup: focus stays in the field.
showIndicator?boolean
Shows the selected item's check at the row's end, with room kept for it.
- Default
true
value?string
The suggestion's value, without an item.
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-disabled?string
Present when the suggestion can't be chosen. Arrow keys skip it.
data-has-icon?string
Present on a suggestion while it holds an icon part.
data-highlighted?string
Present on the highlighted suggestion, which Enter fills in. Focus stays in the field.
data-value?string
Mirrors itemValue.
AutocompleteEmpty
<div> data-slot="autocomplete-empty"
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-empty?string
Present while no suggestion matches.
data-loading?string
Present while results load, with status="loading".
AutocompleteList
<div>
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-empty?string--list-available-heightstringAutocompleteCollection
<div>
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
AutocompleteSeparator
<div> data-slot="autocomplete-separator"
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
useAutocomplete
inputValue?string
The text. Pass it to control it.
defaultInputValue?stringonInputValueChange?(details: AutocompleteInputValueChangeDetails) → void
- Type
(details: AutocompleteInputValueChangeDetails) → void- Parameters
details– { inputValue: string; reason?: AutocompleteInputValueChangeReason }- Returns
void
open?boolean
Whether it's open. Pair with onOpenChange to control it.
defaultOpen?boolean
Whether it starts open, when you don't control open.
onOpenChange?(details: AutocompleteOpenChangeDetails) → void
Called when it opens or closes.
- Type
(details: AutocompleteOpenChangeDetails) → void- Parameters
details– { open: boolean; reason?: AutocompleteOpenChangeDetailsReason }- Returns
void
value?string[]
The chosen items' values. Pass it to control them.
defaultValue?string[]
The value it starts with, when you don't control value.
onValueChange?(details: AutocompleteValueChangeDetails<T>) → void
Called when the value changes.
- Type
(details: AutocompleteValueChangeDetails<T>) → void- Parameters
details– AutocompleteValueChangeDetails<T>- Returns
void
collectionListCollection<T>
The suggestions. Filter it as the text changes, in onInputValueChange.
- Type
ListCollection<T>
allowCustomValue?boolean
Any text is allowed: kept for the other bases' markup.
closeOnSelect?boolean
- Default
true without `multiple`
disabled?boolean
Whether the ete is disabled.
form?string
The id of the form it submits with, when it isn't inside one.
ids?{ input?: string; control?: string }
Ids for the parts: input ties the field to a <label htmlFor>.
- Type
{ input?: string; control?: string }
inputBehavior?"autohighlight" | "autocomplete" | "none"
autohighlight highlights the first suggestion as you type, so Enter
chooses it. autocomplete completes the text inline: the field shows the
rest of the first suggestion that starts with what was typed, selected,
and arrow keys fill in the suggestion they highlight. ArrowRight or End
keeps it; Escape takes it back out. Either way the input value the app
hears stays what was typed.
- Type
"autohighlight" | "autocomplete" | "none"- Default
"none", or "autocomplete" on `Autocomplete`
invalid?boolean
Whether the ete is invalid.
loopFocus?boolean
Whether arrow keys wrap from the last suggestion to the first.
multiple?boolean
Whether several items can be chosen; the text clears after each.
name?string
The name it submits with its form.
onHighlightChange?(details: AutocompleteHighlightChangeDetails<T>) → void
- Type
(details: AutocompleteHighlightChangeDetails<T>) → void- Parameters
details– AutocompleteHighlightChangeDetails<T>- Returns
void
onSelect?(details: AutocompleteSelectionDetails) → void
Runs when an item is chosen, before onValueChange.
- Type
(details: AutocompleteSelectionDetails) → void- Parameters
details– { itemValue: string; value: string[] }- Returns
void
openOnClick?boolean
Whether pressing the field opens the suggestions.
positioning?{ placement?: string; gutter?: number }
Where the suggestions open, as Ark names it (bottom-start) and its gap.
- Type
{ placement?: string; gutter?: number }
readOnly?booleanrequired?boolean
Whether a value is required to submit its form.
selectionBehavior?"clear" | "replace" | "preserve"
What the text becomes once an item is chosen: its label (replace),
what was typed (preserve) or nothing (clear).
- Type
"clear" | "replace" | "preserve"- Default
"replace", or "clear" with `multiple`











