Stat tile
ProOne number and how it moved: what it is, the figure, its change against something, and a small trend under the number. Not an M3 component (@windmorph/react-pro).
import { StatTile, Sparkline } from '@windmorph/react-pro/charts';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Props
StatTile 17 props
What the number is: the tile's name. Untrusted text, rendered as text.
The number. It counts up as the tile first comes into view, then springs to new values.
Formats the number.
A unit, small beside the number ("min"), so a long one never wraps the number.
What assistive technology hears for the number and its unit, in place of what's shown, as the core
Slider'svalueText: the full value where the figure is short ("105,312" for "105K", "8.2 hours" for "8.2 h"). Called with the value it settles on, never a counting one; a value that isn't a number is read aslabels.noValue. Left out, the figure and its unit are read as shown.How the number moved.
Values for a
Sparklineunder the number, oldest first;nullfor no value (a gap).The number's size.
Replaces the change's arrows.
Ref to the outermost element.
The outermost element's id.
Text
Words it says. A
LabelsProvidersets them for the whole app.Said before a rise, whose arrow is decorative.
Said before a fall.
Said before no change.
A number that isn't one (still loading, 0 ÷ 0).
Shown and said after a change that's good news, so the colour is never the only cue (WCAG 1.4.1).
Shown and said after a change that's bad news, likewise.
Shown between the change and its tone in words ("12% on last week · better"), spaces included; screen readers hear
change's sentence instead.labels.changetype(parts: StatTileChangeWords) => stringdefault"Up 12% on last week, better": the direction, the value and the context, then the toneThe change as screen readers hear it, one sentence from its parts, the direction and tone already in words (
up…flat,goodorbad; notonefor neutral news), so a language can put them in its own order.
The id of what describes the tile.
The id of what gives more about it.
Classes for the outermost element. Wins over the defaults via
cn().Classes for each part.
The label, the tile's name.
The number and its unit.
The number.
The unit beside the number.
The change: its arrow, its amount, what it's compared with and its tone in words.
The change's arrow.
What the change is compared with ("on last week").
The dot between the change and its tone in words.
Good or bad news in words, after the change ("better", "worse").
The
Sparkline.
Inline styles for the outermost element.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Sparkline 10 props
The values, oldest first. A few (12 or so) read best; an app averages longer runs.
null, or any value that isn't a finite number, is no value at that place: a gap in the line.Ref to the outermost element.
The outermost element's id.
Text
Names the trend for assistive technology when it stands alone (
role="img"). Left out (witharia-labelledby), it is decorative, as beside the number it shows the trend of.The id of what names the trend, as
aria-labeldoes.The id of what describes a named trend.
The id of what gives more about a named trend.
Classes for the outermost element. Wins over the defaults via
cn().Classes for each part.
Inline styles for the outermost element.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Spec status
Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.
| Item | Status | Details |
|---|---|---|
| A change that is good, bad or neutral news, with a trend | Built | Configuration · Dashboard |
Sizes: md and lg (size) | Built | Variant · Sizes |
A unit and a format of your own (unit, formatValue) | Built | Configuration · Sizes |
A short figure read in full (valueText) | Built | Configuration · Sizes |
| A figure with no value yet | Built | Configuration · Sizes |
| A new period, springing from the figure showing | Built | Use case · Trend |
A Sparkline on its own, named | Built | Configuration · Trend |
| Not an M3 component | Extension | M3 has no chart components; the tile and its sparkline follow M3’s colour roles, type scale and springs, with the chart palette’s first series colour on the trend’s newest value. |
| A number that counts | Extension | The figure counts up once as it first comes into view and springs to each new value, never past it; under reduced motion it changes at once, and the server’s HTML holds the final figure. |
A change that is good, bad or neutral news, with a trend
BuiltConfiguration · Dashboard
Sizes: md and lg (
Builtsize)Variant · Sizes
A unit and a format of your own (
Builtunit,formatValue)Configuration · Sizes
A short figure read in full (
BuiltvalueText)Configuration · Sizes
A figure with no value yet
BuiltConfiguration · Sizes
A new period, springing from the figure showing
BuiltUse case · Trend
A
BuiltSparklineon its own, namedConfiguration · Trend
Not an M3 component
ExtensionM3 has no chart components; the tile and its sparkline follow M3’s colour roles, type scale and springs, with the chart palette’s first series colour on the trend’s newest value.
A number that counts
ExtensionThe figure counts up once as it first comes into view and springs to each new value, never past it; under reduced motion it changes at once, and the server’s HTML holds the final figure.
Theming & tokens
Set the tokens below on the tile or any ancestor. The trend's line, its end dot and the dot's ring come from the shared chart tokens (--wm-chart-quiet, --wm-chart-color-1 and --wm-chart-surface); on a card of another colour than surface, set --wm-chart-surface to it so the ring matches. Only a tile with a trend brings the charts' palette to the page, through its sparkline. className goes on the root; style each part with classNames: label, figure, value, unit, change, changeIcon, context, separator, tone, trend, where trend goes on the sparkline's root. A Sparkline of your own takes className on its root and classNames for what holds its marks, its line and its end dot: plot, trend, point.
| Variable | Default | Paints |
|---|---|---|
--wm-stat-tile-gap | 4px | The space between the label, the figure, the change and the trend. |
--wm-stat-tile-figure-gap | 4px | The space between the number and its unit. |
--wm-stat-tile-change-gap | 4px | The space between the change’s arrow and its words (the amount and what it is compared with, which a space keeps apart). |
--wm-stat-tile-label-color | var(--md-sys-color-on-surface-variant) | What the number is, and what its change is compared with (`context`). |
--wm-stat-tile-value-color | var(--md-sys-color-on-surface) | The number. |
--wm-stat-tile-unit-color | var(--md-sys-color-on-surface-variant) | The unit, small beside the number. |
--wm-stat-tile-change-good-color | var(--md-sys-color-success) | A change for the better: its arrow and words. |
--wm-stat-tile-change-bad-color | var(--md-sys-color-error) | A change for the worse. |
--wm-stat-tile-change-neutral-color | var(--md-sys-color-on-surface-variant) | A change that is neither. |
--wm-stat-tile-change-icon-size | 18px | The change’s arrow. |
| Variable | Default | Paints |
|---|---|---|
--wm-sparkline-height | 36px | The trend’s height, the end dot’s room included. |