skip to content

Autocomplete component

Basic autocomplete function that listens to key events on a text input and fetches suggestions from a specified endpoint.

Example usage

The following is the only HTML the component actually requires:

<input type="text" autocomplete="off" class="c-autocomplete" aria-expanded="false" data-component-autocomplete>

Import the JavaScript:

import autoComplete from '../js/index.js';

autoComplete();

Consult the js/example.js file on how to initialize the component.

Demo