<talos-spark> is a compact inline sparkline — the small sibling of
<talos-trend>. Position and slope carry the shape; the stroke takes the band
colour of the current (last) value, so a glance reads the state without a
legend. Set the series with the data attribute, or stream samples with
el.push(value).
Default
<talos-spark data="20 28 24 40 38 52 60 66 72 80"></talos-spark>
data is a comma/space-separated list, scaled to the [min,max] domain
(default 0–100). A frozen frame still shows the shape — there is no animation
to lose. The host is inline-block; size it with --talos-spark-w /
--talos-spark-h (default 100% × 16px).
Bands — warn & crit on the current value
<!-- last value 72 ≥ warn 60 → warning -->
<talos-spark data="10 18 22 30 44 58 72" warn="60" crit="80"></talos-spark>
<!-- last value 92 ≥ crit 80 → critical -->
<talos-spark data="10 18 30 50 72 86 92" warn="60" crit="80"></talos-spark>
The band is computed from the last sample only. It crosses to warning at
warn and critical at crit — --talos-success / --talos-warning /
--talos-danger respectively. Absent thresholds never trip.
Invert — low = bad
<!-- last value 18 ≤ crit 20 → critical -->
<talos-spark data="90 84 70 55 40 28 18" warn="40" crit="20" invert></talos-spark>
With invert, the comparison flips: warning/critical trip when the current
value falls to/below the threshold. Use it for frame rate, battery, signal —
signals where danger is a value falling.
Fill
<talos-spark data="20 28 24 40 38 52 60 66 72 80" fill></talos-spark>
fill paints the area under the line in the stroke colour at 0.1 opacity —
denser presence in a stat cell without changing the read.
Live stream
const el = document.querySelector("talos-spark");
el.push(74); // append a sample; the oldest is dropped once past `cap` (default 32)
push(value) is the streaming entry point: it appends a sample, trims the
buffer to cap, and re-renders on the next frame. The band recomputes from the
new last value each push.
Behaviour
Imperative API: el.push(value) — preferred for live streams over re-setting
data. Needs at least two samples to draw.
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 |
|---|---|---|---|
data | string | — | initial series, comma/space separated (`points` is a deprecated alias; warns once) |
points | string | — | Deprecated alias of `data`. |
cap | number | 32 | max samples retained. |
min | number | 0 | domain for the y-scale. |
max | number | 100 | domain for the y-scale. |
warn | number | — | band thresholds on the current value. |
crit | number | — | band thresholds on the current value. |
invert | boolean | — | low = bad (flips band direction) |
fill | boolean | — | if present, fill under the line. |
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 |
label | string | — | accessible name, part="caption" (hidden) |
Properties and methods
| Member | Type | Description |
|---|---|---|
push() | method | Append a sample and re-render (the streaming entry point). |
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(area), ::part(line), ::part(svg)
Custom properties read
| Property | Default | Description |
|---|---|---|
--talos-spark-h | 16px | Component knob: set it on the element or an ancestor. |
--talos-spark-w | 100% | Component knob: set it on the element or an ancestor. |