Instruments Instrument contract
// Instrument contract

Instrument contract

The vocabulary every instrument shares: data state, the missing value, number formatting, static motion, the talos:band event and the severity words.

Since 0.13 the instruments speak one vocabulary. Learn an attribute on the gauge and it means the same thing on the meter, the readout and the orbital. This page shows each shared attribute live; the states gallery shows all of them on every instrument at once.

AttributeValuesDefaultWhat it does
statelive loading stale offline unknownlivethe data state, reflected on the host as data-state
updated-atISO 8601 or epoch msnonewhen the reading was taken
stale-aftersecondsnoneage at which the reading turns stale
formatnumber compact percent bytes duration currencynumberhow the number is written
precisionfraction digitsper instrumentdecimals of the number
currencyISO 4217 codeEURwith format="currency"
localeBCP 47 tagnearest lang, then the browsergrouping, decimal mark, currency position
staticflagoffno tween, no scramble, no orbit on this element

Data state

state says how much to trust the reading. The host reflects the effective state as data-state, so your own CSS can follow it.

PREVIEW
<talos-gauge value="72" warn="60" crit="85" unit="%"></talos-gauge>
<talos-gauge value="72" warn="60" crit="85" unit="%" state="loading"></talos-gauge>
<talos-gauge value="72" warn="60" crit="85" unit="%"
  updated-at="2026-12-03T09:00:00Z" stale-after="60"></talos-gauge>
<talos-gauge value="72" warn="60" crit="85" unit="%" state="offline"></talos-gauge>
<talos-gauge value="72" warn="60" crit="85" unit="%" state="unknown"></talos-gauge>
StateRenderingAccessibility
liveband colour, full contrastthe reading
loadingdiagonal hatch on the host, band colour suppressed, text dimmedaria-busy="true" on the host, label ends ”, loading”
stalelast reading kept with its band, host dimmed, age caption in part="age"label ends ”, stale”
offlinetext and graphic in the tertiary text colour, band suppressedlabel ends ”, offline”
unknownband suppressedthe instrument reads “no data”

The effective state is resolved in this order: an explicit loading, stale, offline or unknown wins; then a missing value makes it unknown; then an updated-at older than stale-after makes it stale; otherwise live.

Stale, with an age

Give the instrument the time of its reading and a budget. Once the reading is older than stale-after seconds the host turns stale and shows the age (12s, 4m, 2h, 3d) in part="age". One shared 1 Hz timer, started only while some element on the page has stale-after, keeps every age current and flips a live reading to stale when its budget runs out.

PREVIEW
<talos-stat value="1042" unit="req/s" label="ingest"
  updated-at="2026-12-03T09:00:00Z" stale-after="60"></talos-stat>
<style>
  talos-stat::part(age) { font-size: 0.65rem; }
</style>

The demo sets updated-at from a script when the page loads, so the ages are real: the 40 second reading counts up while you watch.

Missing value

A missing or non-numeric value is not zero. Scalar instruments write —, park the graphic at its minimum, drop the band colour and read “no data” to a screen reader; the host reads data-state="unknown".

PREVIEW
<talos-stat label="no value" unit="%"></talos-stat>
<talos-gauge label="no value" unit="%" warn="60" crit="85"></talos-gauge>

Instruments fed with a collection (histogram, matrix, spark, trend, percentile, status) read unknown while the collection is empty.

Formatting

Every number an instrument writes goes through one formatter over Intl.NumberFormat: the visible text, the aria label and the captions agree. format picks the style, precision the fraction digits, locale the conventions. The same values in en and nl:

PREVIEW
PREVIEW · nl
<talos-stat value="1234567.891" precision="2" locale="en"></talos-stat>
<talos-stat value="1234567" format="compact"></talos-stat>
<talos-stat value="0.4213" format="percent" precision="1"></talos-stat>
<talos-stat value="1536000" format="bytes"></talos-stat>     <!-- 1024 steps: KiB, MiB -->
<talos-stat value="3840" format="duration"></talos-stat>     <!-- seconds in -->
<talos-stat value="1234.5" format="currency" currency="EUR" locale="nl"></talos-stat>
formatInputNotes
numberany numbergroups from five digits (12,345, not 2,026)
compactany numberone fraction digit unless precision is set
percenta ratio0.42 reads 42%
bytesbytes1024 steps: B, KiB, MiB, GiB, TiB
durationsecondsthe two largest units: 1h 4m, 12s
currencyan amountcurrency code, default EUR

Without locale the instrument uses the nearest lang attribute up the tree (crossing shadow roots), then the browser’s language.

Static

static turns motion off on one element: no tween, no scramble, no orbit. The reading still updates, it just lands at once. Use it for dense tables and for print, where the motion carries no information. prefers-reduced-motion does the same for the whole page.

LIVE
<talos-gauge value="40" warn="60" crit="85" unit="%"></talos-gauge>
<talos-gauge value="40" warn="60" crit="85" unit="%" static></talos-gauge>

The demo drives each instrument with its own random walk; the left one of each pair animates to its new value, the right one jumps.

The talos:band event

When a reading crosses into another band the instrument dispatches talos:band with { from, to, value }. It bubbles and is composed, so one listener on a container hears every instrument inside it. It does not fire on the first render, only on a change.

LIVE
    <section id="rack">
      <talos-gauge warn="60" crit="85" unit="%" label="load"></talos-gauge>
      <talos-meter warn="60" crit="85" unit="%" label="queue"></talos-meter>
    </section>
    <script type="module">
      document.querySelector("#rack").addEventListener("talos:band", (e) => {
        const { from, to, value } = e.detail;
        console.log(e.target.localName, from, "→", to, value);
      });
    </script>

    Instruments that fire it: compass, dots, flow, gauge, led, meter, orbital, percentile, range, readout, spark, stat and trend.

    Severity words

    Every input that takes a severity accepts two spellings: the canonical nominal, warning, critical and the short ok, warn, crit, plus idle for “nothing to report”. The numeric band of groundtrack, plane and spacecraft also takes 0, 1, 2. A word the instrument does not know reads idle, never a false green.

    PREVIEW
    <talos-led state="warn"></talos-led>
    <talos-led state="warning"></talos-led>  <!-- same light -->
    <talos-status label="API" channels="nominal,warn,ok,idle"></talos-status>
    WhereTakes
    <talos-led state>a severity word
    <talos-status channels>comma-separated severity words; the worst wins
    <talos-ticker> event levela severity word; a missing level is nominal
    band on groundtrack, plane, spacecraft itemsa severity word or 0, 1, 2

    On <talos-led> the state attribute carries both vocabularies: a severity word sets the light, and a data-state word (loading, stale, offline, unknown) sets the data state with an idle light.

    Per element

    Each instrument page lists the contract attributes it observes in its API table, generated from the manifest. For example, the gauge:

    Attributes

    Generated from custom-elements.json in the installed package. Shared attributes (state, format, static…) behave as the instrument contract describes.

    AttributeTypeDefaultDescription
    value number — current value; missing or non-numeric reads "—" (no data), needle parked at min, no band.
    min number 0 domain range.
    max number 100 domain range.
    warn number — value at/after which band = warning.
    crit number — value at/after which band = critical.
    invert boolean — low = bad (the band trips as the value falls)
    label string — caption under the readout.
    unit string — appended to the readout (e.g. "%")
    sweep number 240 arc sweep in degrees (180–300)
    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

    Properties and methods

    MemberTypeDescription
    .value number | null The current reading; mirrors the `value` attribute (null = no data).

    Events

    EventTypeDescription
    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(dial), ::part(hub), ::part(needle), ::part(readout), ::part(svg), ::part(track), ::part(value-arc)