Use an <article class="kpi"> card to show one headline
figure. It holds a label, the value, a trend chip, a sparkline and a line of
context.
Put the label and value in a <dl> so a screen
reader reads them as a pair. The article is a card, so
filled and outlined work as they do on
cards. KPIs in a grid row stretch to the same height and line up their
footers. The KPI itself is CSS only. The chart component
draws the chart with its own script.
- Revenue
- $48,200
- +12.5%
| Day | Revenue |
|---|---|
| Day 1 | 40.1 |
| Day 2 | 42.3 |
| Day 3 | 41 |
| Day 4 | 43.8 |
| Day 5 | 44.6 |
| Day 6 | 43.9 |
| Day 7 | 45.7 |
| Day 8 | 46.2 |
| Day 9 | 45.8 |
| Day 10 | 48.2 |
- Churn
- 3.1%
- +0.4 pts
| Day | Churn |
|---|---|
| Day 1 | 2.4% |
| Day 2 | 2.5% |
| Day 3 | 2.6% |
| Day 4 | 2.5% |
| Day 5 | 2.8% |
| Day 6 | 2.9% |
| Day 7 | 2.9% |
| Day 8 | 3% |
| Day 9 | 3.1% |
| Day 10 | 3.1% |
- Orders
- 410
- +32%
| Day | Orders |
|---|---|
| Day 1 | 310 |
| Day 2 | 290 |
| Day 3 | 335 |
| Day 4 | 320 |
| Day 5 | 360 |
| Day 6 | 340 |
| Day 7 | 380 |
| Day 8 | 372 |
| Day 9 | 395 |
| Day 10 | 410 |
<article class="kpi outlined">
<dl>
<dt>
<span class="kpi-icon material-symbols-outlined" aria-hidden="true">payments</span>
Revenue
</dt>
<dd class="kpi-value">$48,200</dd>
<dd class="kpi-trend up">+12.5%</dd>
</dl>
<button type="button" class="icon-button kpi-actions" aria-label="Revenue options">
<span class="material-symbols-outlined" aria-hidden="true">more_vert</span>
</button>
<figure class="line-chart sparkline area">
<figcaption class="visually-hidden">Revenue over 10 days, in thousands</figcaption>
<table>
<thead><tr><th>Day</th><th>Revenue</th></tr></thead>
<tbody>
<tr><th>Day 1</th><td>40.1</td></tr>
<!-- … -->
</tbody>
</table>
</figure>
<div class="kpi-footer">Compared with $42,800 last month</div>
</article>
Trend
Add a <dd class="kpi-trend"> chip to compare the value
with an earlier one. up and down add an
arrow. negative marks bad news in the error container
colors, whichever way the number moved. It also turns the first series
of a line, column, bar or mixed chart in the same KPI to the error
color. The arrow is decoration, so the text has to give the
direction, as in +0.4 pts.
<dd class="kpi-trend up negative">+0.4 pts</dd>
Optional parts
Everything after the <dl> is optional and stacks
in source order.
.kpi-icongoes inside the<dt>and draws a tonal icon box. Hide the icon witharia-hidden="true"..kpi-actionson a button or menu trigger places it in the top corner. Name it after the figure, as inaria-label="Revenue options".- A sparkline chart from any chart component. Set its height with the chart's own token, such as
--md-comp-line-chart-height. - A
<progress class="progress">shows progress toward a goal. Name it witharia-label. - A
<p>adds supporting text. .kpi-footercloses the card under a divider, with details or a link.
- Quarterly goal
- 72%
- −3% this week
$720k of $1M booked, with 18 days left.
<article class="kpi filled">
<dl>
<dt>Quarterly goal</dt>
<dd class="kpi-value">72%</dd>
<dd class="kpi-trend down">−3% this week</dd>
</dl>
<progress class="progress" value="72" max="100" aria-label="Quarterly goal"></progress>
<p>$720k of $1M booked, with 18 days left.</p>
</article>
For several figures without charts or actions, use a row of stat tiles instead. They are lighter.
Accessibility
The <dt> and <dd> pairing names
the value. Without it, a screen reader reads a bare number. A
sparkline is not focusable and has no tooltip. Its table stays
in the page, so give it a caption that names the measure and period.
Write the trend's direction and unit in its text, because screen readers
don't announce the arrow or the error colors.
Tokens
Override these on the .kpi. Container color, shape and padding come from the card tokens.
| Token | Default |
|---|---|
--md-comp-kpi-icon-container-color | --md-sys-color-primary-container |
--md-comp-kpi-icon-color | --md-sys-color-on-primary-container |
--md-comp-kpi-trend-container-color | --md-sys-color-secondary-container |
--md-comp-kpi-trend-color | --md-sys-color-on-secondary-container |