Stats
A few figures, each with its label: a definition list of label and value pairs that wraps into columns.
Example
View Code
<dl class="stats">
<div>
<dt>Out now</dt>
<dd>8</dd>
<dd>+1 on last Saturday</dd>
</div>
<div>
<dt>Orders</dt>
<dd>1,284</dd>
<dd><span class="badge" data-variant="success">+12%</span></dd>
</div>
<div>
<dt>Refunds</dt>
<dd>17</dd>
</div>
</dl>
When to use it
A few figures, each with its label: a dashboard row, a "by the numbers" band. Use it when the reader should take in several numbers at a glance.
How it works
A dl with one div per stat. The dt is the label, small and in the muted text color, and it comes first in the source and first on screen. The first dd is the value: large, with tight leading, tabular figures and a strong weight, so a column of them lines up. Any further dd is a note in the label's size, and a badge inside it works for a trend.
View Code
<dl class="stats">
<div>
<dt>Out now</dt>
<dd>8</dd>
<dd>+1 on last Saturday</dd>
</div>
<div>
<dt>Orders</dt>
<dd>1,284</dd>
<dd><span class="badge" data-variant="success">+12%</span></dd>
</div>
<div>
<dt>Refunds</dt>
<dd>17</dd>
</div>
</dl>
The stats wrap into columns at least data-min wide, the attribute grid uses. It defaults to xs. data-gap sets the space between them and defaults to md. data-min="none" puts one stat on each row.
data-size sets the value: sm, md (the default) and lg use the xl, 2xl and 3xl text steps.
A stats has no surface of its own. Put it in a box or a card for a panel.
View Code
<div class="box" data-surface="raised">
<dl class="stats" data-size="lg" data-min="sm">
<div>
<dt>Visitors</dt>
<dd>48,210</dd>
</div>
<div>
<dt>Signups</dt>
<dd>1,904</dd>
<dd><span class="badge" data-variant="success">+8%</span></dd>
</div>
</dl>
</div>
Accessibility
The dt names the value, so a screen reader announces the label with its figure. Keep the label first in the source, and write it so it still makes sense on its own. A value needs its label: do not use stats for a single large number with nothing beside it.
Attributes
| Attribute | Type | Values | Default | Description |
|---|---|---|---|---|
data-min |
enum | none, 3xs, 2xs, xs, sm, md, lg, xl, 2xl |
xs |
The narrowest a column may be before the stats wrap to fewer columns. none puts one stat on each row. |
data-gap |
enum | none, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, xs-sm, xs-md, xs-lg, xs-xl, xs-2xl, xs-3xl, xs-4xl, sm-md, sm-lg, sm-xl, sm-2xl, sm-3xl, sm-4xl, md-lg, md-xl, md-2xl, md-3xl, md-4xl, lg-xl, lg-2xl, lg-3xl, lg-4xl, xl-2xl, xl-3xl, xl-4xl, 2xl-3xl, 2xl-4xl, 3xl-4xl |
md |
Space between the stats. |
data-size |
enum | sm, md, lg |
md |
The size of the value: sm is the xl text step, md the 2xl step, lg the 3xl step. |
Children
> div: at least 1. One stat: a dt with its label, then a dd with the value, then any number of dd notes, such as a badge for a trend.
Tokens
| Token | Description |
|---|---|
--yeti-space-md |
Gap between the stats, when data-gap is absent. |
--yeti-width-xs |
Column minimum, when data-min is absent. |
--yeti-text-sm |
Size of a label and of a note. |
--yeti-text-xl |
Size of the value when data-size is sm. |
--yeti-text-2xl |
Size of the value when data-size is md or absent. |
--yeti-text-3xl |
Size of the value when data-size is lg. |
--yeti-weight-strong |
Weight of the value. |
--yeti-weight-normal |
Weight of a label and of a note. |
--yeti-leading-tight |
Line height of the value. |
--yeti-color-text-muted |
Color of a label and of a note. |
Internal tokens (may change between minor versions)
- `--_yeti-gap` - `--_yeti-min` - `--_yeti-value-size`Accessibility
- A stat is a term and its definition, so a screen reader announces the label with its value. The label comes first in the source and on screen.
Browser support
- Used without guards: grid, font-variant-numeric
- Behind
@supports: nothing
JavaScript
None. This component is CSS only.
Available since 7.0.0.