0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Connects an input to a datalist of suggested values. The user can pick a suggestion or type anything else; on range, colour and date inputs the options become marks and swatches.
Overview
The listattribute takes the id of a <datalist>. Its <option> values become suggestions for the input: a filtered dropdown on text-like inputs, tick marks on a range slider, preset swatches on a colour input. Suggestions never restrict the value; the user can still type anything.
Applies to:<input> of type text, search, url, tel, email, number, range, color, date, month, week, time and datetime-local. Not hidden, password, checkbox, radio, file or the button types, and not <textarea>.
No suggestions (the default). The browser may still offer its own autofill history.
Each <option> supplies a value (what is filled in) and optionally a label or text content, which some browsers show beside the value. Disabled options are not suggested.
Examples
Range slider with labelled stops
On an unstyled type="range" the browser draws the options as tick marks. VB restyles sliders with appearance: none, which drops the native marks, so its data-range renders each option's label under the track and uses the matching label as the slider's spoken value.
Build the options with DOM methods, never by concatenating API data into innerHTML, and encode the query in the URL. An AbortController drops answers that arrive after a newer keystroke.
new Option(text) sets the text and value through properties, so a city named <img onerror=...> stays text.
In Vanilla Breeze
Suggestion arrow.input[list] of a text-like type (no type, text, search, url, email, tel, number) gets a small dropdown arrow on the inline-end side, drawn in currentColor so it follows themes and dark mode, mirrored under dir="rtl" and kept visible in forced colours (src/native-elements/datalist/styles.css). Range, colour, date and time inputs are left alone.
Variants.class="no-arrow" removes the arrow; class="search" swaps it for a magnifier on the inline-start side.
<datalist> itself is display: none.
data-range reads the range input's datalist for labels under the track and for aria-valuetext (src/utils/range-init.js).
Accessibility
The input is exposed as a combobox with a list of suggestions. Arrow Down opens the list in most desktop browsers; Enter picks the highlighted option.
A datalist is not a label. Keep a visible <label>.
Because any value is accepted, don't use list when the user must pick from a fixed set. Use <select> or <combo-box>.
Security
Suggestions often come from user-generated data (other users' city or tag names). Create options with new Option() or textContent and pass query text through encodeURIComponent, as in the example above. Building option markup from strings is an HTML injection path.
Browser support
Datalist on text inputs: Chrome 20, Firefox 4, Safari 12.1. Firefox for Android accepts the attribute but shows no dropdown (bug 1535985). Tick marks on range inputs: Chrome 20, Safari 12.1, Firefox 110 on desktop. Date, time and colour suggestions are not supported in Firefox.
Gotchas
No event says "a suggestion was picked". Listen for input or change on the input.
How typed text is matched against the options is up to the browser, and the dropdown can't be styled.
The browser's own form history can appear alongside your suggestions. autocomplete="off" on the input asks it to leave that history out.