Metric ticker

A strip of figures: label, counter, delta chip, sparkline. It wraps, scrolls sideways, or moves as a marquee.

Anatomy

┌──────────────────────────┬──────────────────────────┬──────────┐
│ MRR                      │ Error rate               │ Queue    │  label · meta, fg-muted
│ $48,200  [↑ +3.2%] ╱╲╱   │ 0.42%  [↓ -12%] ╲╲_      │ 1,204    │  counter · chip · sparkline
└──────────────────────────┴──────────────────────────┴──────────┘
   radius-control · border · surface · a divider before each item
PartTokenWhy
Figureds::counter, md / lg / xl for sm / md / lgRolls on a re-render with the script; plain text without.
Chipstat tile's tints, with arrow-up / arrow-downThe stat tile's rules: sign picks the colour, an arrow says which way. Zero is neutral, no sign. An item's rising: bad swaps the two tones (as stat tile's rising), never the sign or the arrow.
Trendds::sparkline in the item's tone
Dividerborder-s border-divider on every item, list pulled -ms-px, box clippingThe first item on each wrapped line has its rule outside the box, so no line starts with one. not-first: put a rule at the start of every line after the first.

Modes

  • wrap: flex-wrap.
  • scroll: one line, overflow-x-auto, snap-x snap-mandatory, each item snap-start. The scroll box is a named region with tabindex="0".
  • marquee: the list drawn twice in a w-max track moved by the marquee utility (theme.css: ds-marquee from 0 to -50%, or +50% in RTL, over items × 5s, linear, infinite). The second copy is aria-hidden and inert, with no live regions. Paused by animation-play-state on hover, focus-within, and while the pause button is aria-pressed="true".

Reduced motion

The marquee does not move: motion-safe:marquee only, the copy motion-reduce:hidden, the pause button hidden, and the viewport becomes the scroll mode's (overflow-x-auto, snapping). A slower marquee is still motion.

The pause button

A press flips its own aria-pressed, which the track reads through group-has-[…]. No Alpine: the marquee needs none, so its control does not either. The flip is the include's one document listener (press.js, batch 30D), not an inline onclick, which a strict Content Security Policy refuses. Its icon is ds::icon-swap, pause to play.

Accessibility

Rootrole="group", named by label; a list inside
Livenone by default; one item's announce makes it aria-live="polite", aria-atomic
Marqueepausable, stops on hover and focus, still under reduced motion (WCAG 2.2.2)
Deltaarrow and sign as well as colour

Do not

  • Do not make the whole strip a live region. It would never stop talking.
  • Do not let the marquee move under reduced motion, even slowly.
  • Do not put interactive content in the copy. It is inert for a reason.

From the package repo: edit this page on GitHub.

Was this page helpful?