<talos-compass> renders a direction, not a number that happens to be an
angle. On a bar or a sweep gauge, 359° and 1° sit at opposite ends of the track;
on the compass they are neighbours, as they are in the world. The dial is fixed
(N up) and the needle rotates, so the cardinal labels stay upright at every
heading.
Default
<talos-compass heading="72" label="heading"></talos-compass>
The demo walks heading every second. The needle eases to each new bearing the
short way round (350° to 10° turns +20°, never −340°); the readout and colour
are exact at once. Under prefers-reduced-motion the tween is skipped, not the
meaning.
Target and tolerance bands
<talos-compass heading="105" target="90" warn="10" crit="25" label="drifting"></talos-compass>
With target set, warn / crit are off-target tolerances in degrees of
shortest-angle error: the needle turns amber, then red, as the heading drifts
off the target bearing. Without a target the needle is always nominal; a bearing
alone has no wrong value.
Behaviour
All attributes are reactive.
Attributes
Generated from custom-elements.json in the installed package.
Shared attributes (state, format, static…) behave as the
instrument contract describes.
| Attribute | Type | Default | Description |
|---|---|---|---|
heading | number | — | current bearing in degrees, 0..360, wraps; missing reads "—" (no data), needle parked north, no band. |
target | number | — | optional target/desired bearing marker. |
warn | number | — | |heading-target| at/after which band=warning. |
crit | number | — | |heading-target| at/after which band=critical. |
invert | boolean | — | low = bad: the band trips as the error FALLS. |
label | string | — | caption under the readout. |
size | number | 160 | px square. |
format | string | — | number | compact | percent | bytes | duration | currency; the readout's number format |
precision | string | — | fraction digits of the formatted value |
currency | string | — | ISO 4217 code when format=currency |
locale | string | — | BCP 47 locale for formatting; defaults to the page locale |
state | string | — | live | loading | stale | offline | unknown; sets data-state on the host |
updated-at | string | — | time of the last sample (ISO or epoch ms); drives the age caption |
stale-after | string | — | seconds after updated-at at which the element reads stale |
static | string | — | boolean; turns motion off for this element only |
duration | string | — | transition length in ms |
Events
| Event | Type | Description |
|---|---|---|
talos:band | CustomEvent<BandEventDetail> | Fired when the band changes (not on first render): detail { from, to, value }. Bubbles and is composed. |
CSS parts
::part(caption), ::part(cardinals), ::part(dial), ::part(hub), ::part(needle), ::part(readout), ::part(ring), ::part(svg), ::part(target), ::part(ticks)