Metric ticker

A strip of live numbers for a dashboard header or a status bar: each a label, a figure, a change and a trend.

Metric ticker

The figures are counters: with the package's script their digits roll when a re-render changes them; without it the new number simply arrives. Everything else is plain Blade and CSS, the marquee included.

Use it

<x-ds::metric-ticker label="Live metrics" :items="[
    ['label' => 'MRR', 'value' => $mrr, 'format' => ['prefix' => '$'], 'delta' => 3.2, 'trend' => $mrrTrend, 'tone' => 'success'],
    ['label' => 'Error rate', 'value' => $errors, 'format' => ['suffix' => '%', 'decimals' => 2], 'delta' => -12, 'rising' => 'bad'],
    ['label' => 'Queue', 'value' => $queued, 'href' => route('horizon.index')],
]" />

With Livewire, wire:poll the component that holds it and the figures roll.

Props

PropTypeDefaultWhat it does
itemsarray[]The figures, in order. Each label and value; see below.
sizesm md lgmdThe figures at body, title or display size.
labelstringMetricsThe strip's name.
dividersbooltrueA rule between the items.
scrollwrap scroll marqueewrapSee Modes.
pauseLabelstringPauseThe marquee's pause button's name.

Per item:

KeyWhat it does
label, valueNeeded. A value that is not a number is shown as written.
formatThe counter's format: prefix, suffix, decimals, compact.
deltaA percentage, as on stat tile: its sign picks the colour, and an arrow says which way.
risinggood (default) or bad: what a rise means. With bad a fall is drawn in success and a rise in danger; the sign and the arrow stay as they are. The same word as stat tile's and slope chart's.
trendA list of numbers, drawn as a sparkline in tone.
tonesuccess warning danger accent neutral.
hrefMakes the item a link.
announceMakes this one figure a polite live region.

Modes

  • wrap: the items flow onto as many lines as they need. The default.
  • scroll: one line that scrolls sideways, snapping to each item. The scroll box takes focus so a keyboard can scroll it.
  • marquee: one line, moving. It pauses while the pointer or focus is on it, and has a pause button. Under reduced motion it does not move: it is the scroll row. The loop's second copy is hidden from assistive technology and inert.

Accessibility

  • A named group holding a list. Each figure reads as its label and number.
  • Not a live region. A ticker that spoke every change would never stop. Mark the one figure someone is waiting on with announce.
  • Every delta has an arrow as well as a colour, and a sign.
  • The marquee meets WCAG 2.2.2: it can be paused, and it stops for hover, focus and reduced motion.

Don't

  • Don't use the marquee for figures people need to read. Use wrap.
  • Don't announce more than one figure.
  • Don't put a headline number here. Use a stat tile.

More in specs/metric-ticker.md.


From the package repo: edit this page on GitHub.

Was this page helpful?