Web component / unpkg

<dynamic-datalist>

This page loads the guarded definition helper from unpkg and registers the element when supported. See the README for the API.

Initial suggestions

The bootstrap attribute loads suggestions without waiting for typing. This page uses mock responses; your application must provide its own endpoint. Without JavaScript, or if the module fails, you can still enter a value or use the initial suggestion. A failed request keeps the current suggestions.

<dynamic-datalist endpoint="/api/demo" bootstrap>
  <label for="demo-input">Search</label>
  <input id="demo-input" name="demo" list="demo-options" />
  <datalist id="demo-options">
    <option>Popular option</option>
  </datalist>
</dynamic-datalist>

<script type="module">
  import { defineDynamicDatalist } from 'https://unpkg.com/@aarongustafson/dynamic-datalist@latest/define.js?module';

  defineDynamicDatalist();
</script>
Choose a suggestion or type your own value.