- Docs
Autocomplete, end to end
What @samline/autocomplete does, how its combobox behaves and where to find installation, examples, options and the complete API.
@samline/autocomplete turns an existing text input into an accessible combobox that searches a remote endpoint, an async function or a local array. You own the data and its shape; the package owns debounce, cancellation, request ordering, caching, accent-insensitive matching, highlighting, the listbox, keyboard interaction, announcements, events and cleanup.
Choose your next step
Installation
Package / ESM and HTML / CDN, and the first working search.
ExamplesLive previews with the complete, copyable source of each one.
OptionsEvery option with its default, from source to messages.
API referencecreateAutocomplete, the controller, helpers, the registry and events.
How a search works
- Typing schedules a search after
debouncems once the query reachesminLengthcharacters. - A new search aborts the previous request; responses that arrive late are ignored.
- The response goes through
parseResponseandmapResponse, then the firstmaxResultssuggestions are rendered as options. - Choosing an option writes
getValue(suggestion)into the input, closes the list and dispatchesautocomplete:select. - Escape, Tab, clicking outside, selecting or
close()cancel the pending search and abort the request in flight.