Autocomplete
An editable text input with filtered suggestions and free-text submission.
Base Autocomplete pairs a single-line text input with a filterable suggestion list, supporting both option selection and free-text completion.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
Anatomy
Section titled “Anatomy”Compose Root, Input (or Textarea), Content, Item, Empty, Trigger, and optional structural grouping parts Group, Label, and Separator:
Roottracks the committedvalue, the live queryinputValue, and derived completion states (completionQuery,activeCompletion,completionPreview).- Choosing a suggestion commits its resolved completion text (
Item.completionText, falling back totextValueorvalue); pressingEnterin single-lineInputwith no active match commits the current free text. - Built-in filtering matches
textValue,keywords, andcompletionTextcase- and diacritic-insensitively. Setfilter={false}to supply pre-filtered items from your application. Groupbinds its unique in-scopeLabelviaAUTOCOMPLETE_GROUP_FAMILY(failing closed on missing or duplicate labels) and hides automatically when zero descendant items match;Separatoris decorative and contentless; nestedRootinstances isolate both naming and group visibility.Emptyreflects whether any items match; disabled and duplicate-valued items cannot be committed.
Completion targets and keyboard behavior
Section titled “Completion targets and keyboard behavior”completionMode('list' | 'inline' | 'both' | 'none', default'list') projects toaria-autocomplete. In'inline'and'both'modes, keyboard navigation previews the active item’s completed text in uncontrolled text controls while preserving the filter query, andEscapecloses and restores the typed query; pointer hover never rewrites input text, and controlledinputValueis never silently overwritten.completionTargetsupports whole-input replacement ('input', default) and caret-bounded token replacement ('token'withcompletionDelimiterandcompletionPrefix, e.g.@mentions or comma-delimited lists), replacing only the active span and reacting to selection changes.Textareamay replace single-lineInputas a multiline completion target: native arrow keys and newline insertion remain intact while closed, and list navigation / active-itemEntercommit activate while open.value,inputValue, andopencan each be controlled independently via their matching change events; active IME composition never mutates or commits a completion target.
Root Props
Section titled “Root Props”Pass value, inputValue, or open to control the corresponding state.
| Prop | Type | Default |
|---|---|---|
value | string | — |
defaultValue | string | '' |
inputValue | string | — |
defaultInputValue | string | '' |
open | boolean | — |
defaultOpen | boolean | false |
disabled | boolean | false |
readOnly | boolean | false |
filter | boolean | true |
loop | boolean | true |
a11yLabel | string | '' |
completionMode | 'list' 'inline' 'both' 'none' | 'list' |
completionTarget | 'input' 'token' | 'input' |
completionDelimiter | string | ' ' |
completionPrefix | string | '' |
Other parts
Section titled “Other parts”- Input:
placeholder,a11yLabel, andnamedefault to''. - Textarea: inherits
Inputprops plus optionalrows(positive integer) andwrap('soft' | 'hard', default'soft'). - Content:
sidedefaults to'bottom',alignto'start',sideOffsetto4, andcollisionPaddingto8. - Item:
value,textValue,completionText, andkeywordsdefault to'';disableddefaults tofalse. - Group / Label / Separator / Empty: no props;
Groupexposesvisiblestate. - Trigger:
disableddefaults tofalse.