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…
Styled range slider with a filled track, an optional value bubble, prefix/suffix and locale formatting, tick markers and datalist labels. Covers data-range, data-bubble, data-prefix, data-suffix and data-markers.
Overview
data-range enhances a native <input type="range">: a styled track whose filled part follows the thumb, and, on request, a value bubble above the thumb, tick marks at each step, and the labels of a linked <datalist> under the track. The input stays a real form control and fires its native input and change events.
The bubble, ticks and labels are visual. What a screen reader hears comes from aria-valuetext, which the script keeps in step with the bubble.
The script wraps the input in a .range-wrapper element and adds the bubble, markers and labels inside it. Without JavaScript the input is a standard browser slider.
Turns on the enhancement for input[type="range"]: wrapper, styled track and thumb, filled track.
data-bubble
boolean
off
Shows the formatted value in a bubble centred over the thumb.
data-prefix
string
""
Text before the value, e.g. $. Used in the bubble and in aria-valuetext.
data-suffix
string
""
Text after the value, e.g. % or km. Used in the bubble and in aria-valuetext.
data-markers
boolean
off
Draws a tick at every step from min to max. Skipped when that would be more than 100 steps.
list
datalist id
—
Native attribute. Each <option> becomes a label under the track at its value (its label, else its value). When the slider sits on an option with a label, that label is the spoken value.
min, max, step
native
0, 100, 1
Read for the fill, bubble and tick positions. max="0" is honoured, so ranges like −100 to 0 work.
data-range-init
boolean
—
Set by the script. Informational; no styles depend on it.
Number format. The value is formatted with Intl.NumberFormat in the locale of the closest [lang] ancestor, so 1500 shows as 1,500 in English and 1.500 in German. Decimal places follow step (or the value itself).
Events
No custom events. The slider fires the native input event while dragging and change when released. The fill, bubble and aria-valuetext update on both, and again after the owning form is reset.
Setting input.value from a script does not fire an event, so dispatch one to refresh the display:
The script writes two custom properties on the .range-wrapper; the input and the bubble inherit them:
Custom property
Set by
Meaning
--range-pct
script, on .range-wrapper
Value position as a percentage, 0% to 100%. Drives the filled track.
--range-frac
script, on .range-wrapper (and on each datalist label)
The same position as a number from 0 to 1. Positions the bubble and labels.
--range-track-bg
you (token in src/tokens/forms.css)
Colour of the unfilled track. Defaults to --control-border.
Read --range-pct and --range-frac; do not set them, or the display stops following the value. The fill colour is --color-interactive; the thumb size is private. The hooks for further styling are the generated classes .range-wrapper, .range-bubble, .range-markers and .range-labels.
Using the generated hooks
1234567891011121314
/* A warning-coloured fill: the input inherits --range-pct from its wrapper. (The built-in fill also flips the gradient under RTL; do the same if needed.) */.range-wrapperinput.heat {background: linear-gradient(to right,var(--color-warning) var(--range-pct),var(--range-track-bg) var(--range-pct));}/* Restyle the bubble */.range-bubble {background: var(--color-primary);color: var(--color-text-on-primary);border-color: transparent;}
Accessibility
aria-valuetext carries the prefix, formatted number and suffix ("$1,500", "80%"), or the datalist label ("Good") when the value matches one. A slider with no prefix, suffix or label keeps the plain number. An aria-valuetext you author is left alone.
The bubble (an <output>), the ticks and the datalist label row are aria-hidden, so the value is announced once, not again from a live region.
Native keyboard support is unchanged: arrow keys step, Page Up/Page Down take larger steps, Home/End jump to min and max.
The slider needs a visible <label>.
In right-to-left text the fill grows from the right and the bubble and labels stay centred on the thumb.
In forced-colours mode the fill is Highlight on a CanvasText track and the thumb is outlined, so the value stays visible.