autocomp.js

A super tiny Javascript autocomplete / autosuggestions library. Zero depend...

README

autocomp.js


A super tiny Javascript autocomplete / autosuggestion library. Zero dependencies and ~800 bytes minified + gzipped.

[View demo](https://knadh.github.io/autocomp.js)

Usage


Node

  1. ```shell
  2. npm install @knadh/autocomp
  3. ```

  1. ```javascript
  2. import { autocomp } from @knadh/autocomp;

  3. autocomp(document.querySelector("#q"), {
  4. onQuery: async (val) => {
  5.   // fetch() or whatever that fetches/generates results.
  6.   return ["results", "here"];
  7. },

  8. onSelect: (val) => {
  9.   alert(val);
  10.   return val;
  11. }
  12. });
  13. ```

Check the demo source to see advanced usage and basic CSS styles.

ES6 module

Check the [demo source](https://github.com/knadh/autocomp.js/blob/master/docs/index.html) to use the lib in `