Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/knadh/autocomp.js

A super tiny Javascript autocomplete / autosuggestions library. Zero dependencies, ~800 bytes min+gzip.
https://github.com/knadh/autocomp.js

autocomplete autosuggestions search suggestions typeahead

Last synced: 6 days ago
JSON representation

A super tiny Javascript autocomplete / autosuggestions library. Zero dependencies, ~800 bytes min+gzip.

Awesome Lists containing this project

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)

[![demo](https://github.com/knadh/autocomp.js/assets/547147/8bfaa03c-46a0-4e4e-a127-914120265009)](https://knadh.github.io/autocomp.js)

## Usage

### Node
```shell
npm install @knadh/autocomp
```

```javascript
import { autocomp } from @knadh/autocomp;

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

onSelect: (val) => {
alert(val);
return val;
}
});
```

Check the [demo source](https://github.com/knadh/autocomp.js/blob/master/docs/index.html) 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 `` directly on an HTML page.

Licensed under the MIT License.