Skip to content

hd-battery

Live preview

<hd-battery level="0.64" state="charging" size="32px"></hd-battery>

Attributes and example

hd-battery

A battery whose charge fills it from the bottom: while it charges a wave rolls on the surface, while it gives power a shimmer runs down through it; low (under 20%) it turns warn. Reduced motion: still; e-ink snaps.

AttributeWhat it is
levelHow full, 0–1. Or a live capability of any device, followed and fitted into its own range: {{ cap.measure_battery }} (0–100) just works.
stateWhat it does.One of charging, giving, idle. Default idle.
sizeIts width (CSS), e.g. 28px; or set --size.Default 28px.
labelAccessible label; otherwise the level and state.
<hd-battery level="0.64" state="charging" size="32px"></hd-battery>

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-ease-out
The easing of most movement.
--hd-good
All is well: locked, closed, cheap.
--hd-lit
The warm colour of a device that is on.
--hd-motion-slow
A slow change, like a theme switching.
--hd-motion-tempo
CSS input read by hd-battery.
--hd-text-muted
Labels and secondary text.
--hd-warn
Worth a look: a low battery, a door open for a while.

Style the host

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