Autocomplete looks small but packs most frontend hard problems into one input: networking, caching, concurrency, accessibility, and performance.
Functional
- Show suggestions as the user types, with the matching part highlighted.
- Navigate suggestions by keyboard (↑ ↓ Enter Esc) and mouse/touch.
- Selecting a suggestion navigates or fills the input; Enter with no selection submits the raw query.
- Show recent searches when the input is focused but empty.
- Support suggestion types: queries, products with thumbnails, categories.
Non-functional
- Latency: suggestions within ~150 ms of a pause in typing. Every keystroke must stay responsive (INP < 100 ms for the input itself).
- Efficiency: don't send a request per keystroke; reuse results.
- Correctness: never show results for an older query after a newer one.
- Accessibility: follows the WAI-ARIA combobox pattern; screen readers announce the number of results and the active option.
- Resilience: handles slow networks and errors without blocking typing.
Generic component or product-specific? Decide early. A reusable Autocomplete in the design system should be headless or compound (see the patterns path) with the data source injected. The search team then owns ranking and suggestion types.