Range

<o-range> is a circular range slider: two handles on one ring pick a start and an end, numbers or times of day.

Drag a handle, drag the band to move both, or tap the track.

The dial is a whole day, so the band wraps through midnight. The track and the band are two interactive <o-arc>s on orbit-12: the band's ring takes the start as its --o-from and the span as its value. Each handle is a satellite on the same lane, placed by its angle, and the hours are satellites spread around an inner ring.

Numbers

Without mode, the range is a pair of numbers between min and max on a 270° arc, and the end never comes before the start. The middle shows the span, formatted like any kit readout.

Attributes

AttributeDefaultWhat it does
start / end22:00 / 06:00, or a quarter / three quarters of the rangeThe two values: HH:MM in time mode, numbers otherwise. They are also the default a form reset returns to; the attributes follow the handles.
modenumberstime makes the dial a 24-hour day, in minutes.
hoursfrom the locale12 or 24: how times read, 10:30 PM or 22:30. The value is always 24-hour.
min / max0 / 100The range of a number dial. See Shared options.
step1, or 5 minutesSnapping grid for handles and keys. any turns it off.
wrapon for timeA number dial that goes round, like hues or angles: the start can come after the end.
min-span / max-spanone step / the whole dialLimits for the span, in values (minutes in time mode, or h:mm). A handle pushed past a limit carries the other one along.
range / from270 / autoArc span and start angle of a number dial that does not wrap.
labelA caption under the span. It is also the accessible name of the group.
start-label / end-labelStart / EndAccessible names of the handles.
start-icon / end-iconmoon, sun, bell, a short text or a small inline SVG.
ticks48 / 40Marks around the inside of the band; 0 hides them.
numbers12 / 4 / 5Labels on the dial; 0 hides them.
fill / track#4fd1c5 / #1f2630Band and track colors.
thickness2.4Band thickness in lanes. The handles follow it.
nameField name: the range submits start-end with the form. See Forms.
disabledoffDimmed, out of the tab order and not submitted. A disabled <fieldset> does the same.
size280pxWidth of the widget.
glowoffA glow in the band color.
format, decimals, currency, unit, localeNumber format of a number dial. See Shared options.
themedark, light or glass. See Shared options.

Properties and events

NameWhat it does
value"22:30-06:45" or "20-80". Setting it (also as [start, end]) fires no event.
start, endOne end each: "22:30" in time mode, a number otherwise.
spanThe distance from start to end, in values (minutes in time mode). Read only.
form, labels, defaultValue, validityAs on a native input.
formatterA function that writes the numbers. It also gets kind: 'span' for the readout in the middle.
inputFires on every change you make. event.detail has value, start, end and span.
changeFires once a drag ends with a different value, and on each key press.
sleep.addEventListener('change', (e) => save(e.detail.start, e.detail.end))
sleep.value = '23:00-07:00'

Styling

PropertyDefaultWhat it does
--ok-fill#4fd1c5Band, and the icons on the handles.
--ok-track#1f2630Track.
--ok-range-handle--ok-surfaceHandle color.
--ok-range-icon--ok-fillIcon color.
--ok-tickcurrentColorDial marks.
--ok-focus#3da9fcFocus ring of a handle.
--ok-font-size8cqminBase font size, as a share of the widget.

More examples

Opening hours with limits

A 24-hour clock with a 15-minute step, at least two hours and at most twelve.

Hues that go round

With wrap, a number dial is a circle too: here a band of hues from magenta to orange.

Light, in a form

Accessibility

The range is a role="group" named by label (or “Time range” / “Range”), with two handles that are each a role="slider" and a tab stop, named by start-label and end-label. Each has aria-valuenow, aria-valuemin, aria-valuemax and an aria-valuetext that reads the time or number and the span, like “22:30, span 8 h 15 min”.

Arrow keys move the focused handle one step, Page Up and Page Down ten steps (an hour in time mode), Home and End go to the ends. Shift with an arrow moves both handles. A handle pushed past min-span or max-span carries the other one, so keys never get stuck.