Stats

Metric cards and stat displays with numbers, labels, and change indicators. Perfect for dashboards and data summaries.

Overview

Stats patterns display key metrics at a glance. They combine large numbers with supporting context like labels, change indicators, and icons to help users quickly understand important data.

Key features:

  • Semantic HTML using <figure>, <figcaption>, and <data>
  • Machine-readable values via the value attribute on <data>
  • Trend indicators using data-trend attributes
  • Scoped CSS for minimal class usage
  • Responsive grid layout

Simple Number Grid

A clean grid of stat figures with labels and large numbers. Each stat uses a <figure> element with a <figcaption> for the label and <data> for the machine-readable value.

With Change Indicators

Stats with trend indicators showing change from a previous period. Uses <small> with a data-trend attribute for semantic color styling. The percentage change is wrapped in a nested <data> element for machine-readability.

Card-Based Stats

Each stat in its own card container with an icon for visual distinction. Uses data-layout="cluster" on the figure for horizontal layout and <layout-stack> for vertical content stacking.

Semantic Benefits

This pattern uses semantic HTML elements that provide meaning beyond visual presentation:

  • <figure>: Groups the stat as a self-contained unit of content
  • <figcaption>: Provides the label/caption for the figure
  • <data value="">: Contains machine-readable values for parsing by scripts or assistive technologies. The value attribute holds the raw number while the text content shows the formatted display. Can be nested inside <small> to make change percentages machine-readable too
  • <small>: Indicates secondary information (the trend/change indicator)

Usage Notes

  • Machine-readable values: Always include the raw number in the value attribute (e.g., value="24521" for "24,521" or value="0.032" for "3.2%"). Use nested <data> inside trend indicators for machine-readable change values (e.g., <data value="0.125">+12.5%</data>)
  • Color semantics: Use data-trend="up" for positive trends and data-trend="down" for negative trends
  • Accessibility: The semantic structure helps screen readers understand the relationship between labels and values
  • Responsive: The grid automatically adjusts column count based on container width
  • Context: Include context in trend indicators (e.g., "vs last month") so users understand what the change refers to

Related

Data Element

Machine-readable values

Figure Element

Self-contained content

Layout Card

Card container element

Dashboard

Full dashboard layouts with stats