Awesomplete

1.1.7 · abandoned · verified Wed Apr 22

Awesomplete is an ultra-lightweight, customizable, and dependency-free autocomplete widget designed for modern browsers. It provides an accessible solution for adding suggestion lists to input fields, aiming to fill the gap where native `<datalist>` elements might fall short in customization or functionality. The current stable version is 1.1.7, which was last published to npm in 2018. While effective for its intended purpose, the project appears to be unmaintained, with no significant updates or active development in recent years. Its key differentiators include its minimal footprint (2KB minified & gzipped), zero dependencies, and the ability to be easily integrated via HTML attributes or a simple JavaScript API, offering flexibility for various use cases.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates both declarative HTML-based setup with `data-list` and programmatic JavaScript instantiation for an autocomplete input, showing how to link a custom list of suggestions and configure basic options like `minChars` and `autoFirst`.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Awesomplete Quickstart</title>
  <link rel="stylesheet" href="https://unpkg.com/awesomplete@1.1.7/awesomplete.css" />
</head>
<body>
  <h1>Awesome Autocomplete</h1>

  <label for="my-input">Select a Programming Language:</label>
  <input id="my-input" class="awesomplete" data-list="Ada, Java, JavaScript, Brainfuck, LOLCODE, Node.js, Ruby on Rails" />

  <h2>Programmatic Example</h2>
  <label for="custom-input">Choose a Fruit:</label>
  <input id="custom-input" />

  <script src="https://unpkg.com/awesomplete@1.1.7/awesomplete.js" async></script>
  <script>
    window.addEventListener('load', () => {
      // Example 1: Declarative setup using HTML attributes (data-list)
      // The input with class="awesomplete" and data-list is automatically processed.

      // Example 2: Programmatic setup for more control
      const inputCustom = document.getElementById('custom-input');
      new Awesomplete(inputCustom, {
        list: [
          'Apple', 'Apricot', 'Avocado', 'Banana', 'Blackberry', 'Blueberry',
          'Cherry', 'Coconut', 'Cranberry', 'Date', 'Dragonfruit', 'Durian',
          'Elderberry', 'Fig', 'Grape', 'Guava', 'Kiwi', 'Lemon', 'Lime',
          'Mango', 'Melon', 'Nectarine', 'Orange', 'Papaya', 'Passion Fruit',
          'Peach', 'Pear', 'Pineapple', 'Plum', 'Pomegranate', 'Raspberry',
          'Strawberry', 'Watermelon'
        ],
        minChars: 1, // Show suggestions after 1 character
        autoFirst: true // Highlight the first item automatically
      });

      // Event listener example (optional)
      inputCustom.addEventListener('awesomplete-selectcomplete', (e) => {
        console.log('Selected:', e.text.value);
      });
    });
  </script>
</body>
</html>

view raw JSON →