Skip to content

hd-slider

Live preview

<hd-slider bind="{{ cap.dim }}" label="Brightness"></hd-slider>

Attributes and example

hd-slider

on change

A slider bound to a numeric capability (dim, target temperature, volume…) with bind (or the explicit form: value with data-hd-on-change). It sends the value once, on release. With fill it is the whole tile: put it in the tile and the template’s own content inside it (<hd-slider fill bind="…">name and value</hd-slider>); its value is a wash rising from the bottom (or growing from the left) with a grip on its edge, dragged anywhere by how far it moves; a tap glides it to the tapped spot, or with tap="tile" is the tile’s own tap. A fill slider’s colours are CSS properties, any colour or gradient: --hd-slider-tone (the edge and grip), --hd-slider-fill (the wash, laid across the whole tile and uncovered as it grows) and --hd-slider-track (the rest).

AttributeWhat it is
bindThe capability it is bound to, e.g. {{ settings.light.cap.dim }} (the whole capability, no .value): it shows its value, takes min, max and step from it, and sends changes back (shown at once, sprung back if refused, range checked). A device that is unavailable shows its last value, disabled.
valueThe explicit form instead of bind: what it shows, e.g. {{ cap.dim.value }} (or a live capability, followed); a change only goes to data-hd-on-change, which decides what it does. Without a handler it can’t be changed.
minMinimum; defaults to the capability’s.
maxMaximum; defaults to the capability’s.
stepStep; defaults to the capability’s.
toneTrack colour; warmth is a cool-to-warm track for colour temperature, muted a dimmed one for something switched off.One of accent, lit, cool, warmth, muted. Default accent.
labelAccessible label.
fillThe whole tile is the slider: it fills the box it sits in (give that box position: relative and rounded corners of its own), the content inside it drawn on top.
directionWhich way a fill slider grows; left out, right in a clearly wide box (5:4 and wider) and up in any other.One of up, right.
tapWhat a tap without dragging does on a fill slider: set glides it to the tapped spot; tile leaves the tap to the tile around it (switching the lamp), so only a drag changes the value.One of set, tile. Default set.
<hd-slider bind="{{ cap.dim }}" label="Brightness"></hd-slider>

Styling

Set CSS variables on the component element. Its internal elements live in Shadow DOM; only the exposed named parts can be styled with ::part.

--hd-accent
The theme’s accent: active controls, links, highlights.
--hd-border
Lines round tiles and between parts.
--hd-border-width
How thick borders are.
--hd-canvas
The page behind the tiles: a colour or a gradient.
--hd-control-radius
The corners of switches, sliders, pills and badges (999px for pills).
--hd-cool
The cool counterpart: cooling, cold water, low prices on some themes.
--hd-ease-out
The easing of most movement.
--hd-ease-spring
A springy easing, for things that bounce into place.
--hd-focus
The outline round what has keyboard focus.
--hd-font-mono
The monospaced font of small labels.
--hd-lit
The warm colour of a device that is on.
--hd-motion-base
An ordinary change, like a value sliding.
--hd-motion-fast
A quick change, like a press. 0ms when nothing may move.
--hd-overlay
Menus, dialogs and popups over the page.
--hd-slider-fill
CSS input read by hd-slider.
--hd-slider-tone
CSS input read by hd-slider.
--hd-slider-track
CSS input read by hd-slider.
--hd-surface
A tile’s colour.
--hd-surface-raised
Something on a tile that stands out from it, like a button.
--hd-text
Text and big numbers.
--hd-text-faint
The quietest text: hints, units, times.
--hd-text-muted
Labels and secondary text.
--hd-thumb-h
The height of a slider’s handle.
--hd-thumb-radius
The corners of a slider’s handle.
--hd-thumb-w
The width of a slider’s handle.
--hd-track
The empty part of a slider, bar or ring.
--hd-track-height
A slider’s track thickness.

Style the host

hd-slider {  --hd-accent: #2563eb;  max-width: 100%;}
Theme variables