Skip to content

KPI card

BetaData displayOpen in the workshop

One headline number, its change against the previous period, and a sparkline.

.xg-card.xg-kpi > .xg-kpi__label + .xg-kpi__value + .xg-kpi__meta (.xg-delta--up|--down|--flat) + svg.xg-kpi__spark · grid: .xg-kpi-grid

Example and markup

Live, from xg-ui.css and xg-ui.js. Switch the brand and mode on the example itself, or for the whole site in the header.

KPI card
Revenue $150.2K +12.4%vs previous 30 days
Fill rate 92.4% +3.1 ptsvs previous 30 days
eCPM $2.41 −0.4%vs previous 30 days
Requests 1.82B 0.0%vs previous 30 days
Markup
<div class="xg-kpi-grid">
<div class="xg-card xg-kpi">
<span class="xg-kpi__label">Revenue</span>
<span class="xg-kpi__value">$150.2K</span>
<span class="xg-kpi__meta">
<span class="xg-delta xg-delta--up">+12.4%</span>vs previous 30 days</span>
<svg class="xg-kpi__spark" viewBox="0 0 120 36" preserveAspectRatio="none" aria-hidden="true">
<path class="area" d="M0.0 33.0 L13.3 26.3 L26.7 29.7 L40.0 21.3 L53.3 23.0 L66.7 14.7 L80.0 18.0 L93.3 9.7 L106.7 11.3 L120.0 3.0 L120 36 L0 36 Z"/>
<path class="line" d="M0.0 33.0 L13.3 26.3 L26.7 29.7 L40.0 21.3 L53.3 23.0 L66.7 14.7 L80.0 18.0 L93.3 9.7 L106.7 11.3 L120.0 3.0"/>
</svg>
</div>
<div class="xg-card xg-kpi">
<span class="xg-kpi__label">Fill rate</span>
<span class="xg-kpi__value">92.4%</span>
<span class="xg-kpi__meta">
<span class="xg-delta xg-delta--up">+3.1 pts</span>vs previous 30 days</span>
<svg class="xg-kpi__spark" viewBox="0 0 120 36" preserveAspectRatio="none" aria-hidden="true">
<path class="area" d="M0.0 33.0 L13.3 30.3 L26.7 31.6 L40.0 26.2 L53.3 22.1 L66.7 19.4 L80.0 15.3 L93.3 12.5 L106.7 8.5 L120.0 3.0 L120 36 L0 36 Z"/>
<path class="line" d="M0.0 33.0 L13.3 30.3 L26.7 31.6 L40.0 26.2 L53.3 22.1 L66.7 19.4 L80.0 15.3 L93.3 12.5 L106.7 8.5 L120.0 3.0"/>
</svg>
</div>
<div class="xg-card xg-kpi">
<span class="xg-kpi__label">eCPM</span>
<span class="xg-kpi__value">$2.41</span>
<span class="xg-kpi__meta">
<span class="xg-delta xg-delta--down">−0.4%</span>vs previous 30 days</span>
<svg class="xg-kpi__spark" viewBox="0 0 120 36" preserveAspectRatio="none" aria-hidden="true">
<path class="area" d="M0.0 8.0 L13.3 13.0 L26.7 3.0 L40.0 18.0 L53.3 23.0 L66.7 13.0 L80.0 28.0 L93.3 23.0 L106.7 33.0 L120.0 28.0 L120 36 L0 36 Z"/>
<path class="line" d="M0.0 8.0 L13.3 13.0 L26.7 3.0 L40.0 18.0 L53.3 23.0 L66.7 13.0 L80.0 28.0 L93.3 23.0 L106.7 33.0 L120.0 28.0"/>
</svg>
</div>
<div class="xg-card xg-kpi">
<span class="xg-kpi__label">Requests</span>
<span class="xg-kpi__value">1.82B</span>
<span class="xg-kpi__meta">
<span class="xg-delta xg-delta--flat">0.0%</span>vs previous 30 days</span>
<svg class="xg-kpi__spark" viewBox="0 0 120 36" preserveAspectRatio="none" aria-hidden="true">
<path class="area" d="M0.0 23.0 L13.3 3.0 L26.7 33.0 L40.0 13.0 L53.3 23.0 L66.7 3.0 L80.0 13.0 L93.3 23.0 L106.7 13.0 L120.0 13.0 L120 36 L0 36 Z"/>
<path class="line" d="M0.0 23.0 L13.3 3.0 L26.7 33.0 L40.0 13.0 L53.3 23.0 L66.7 3.0 L80.0 13.0 L93.3 23.0 L106.7 13.0 L120.0 13.0"/>
</svg>
</div>
</div>

States

Hover, focus and pressed are forced here with .is-hover, .is-focus and .is-active so they can be seen side by side; in a product they come from :hover, :focus-visible and :active.

KPI card: every state
StateUp (good)Down (bad)Flat
Delta
Revenue $168.8K +12.4%vs previous 30 days
Revenue $131.7K −12.3%vs previous 30 days
Revenue $150.2K 0.0%vs previous 30 days

When to use it

Use it for

the top row of a dashboard: revenue, impressions, fill rate, eCPM.

Not for

more than five on one row; numbers without a period.

Rules

  • The value uses the display font, tabular figures and a short unit: $150.2K, 92.4%, 1.8B.
  • The delta says what it compares to (“vs previous 30 days”). Up is green and down is red only when up is good; for costs, invert the classes.
  • A true minus sign (−) for negative numbers.
  • The sparkline has no axes and is decorative; the number carries the meaning.
  • Four cards per row on desktop, two on tablet, one on phone.

Accessibility

  • Delta direction is in the text (▲/▼ and the sign), never only in color.
  • Sparkline is aria-hidden.

Every color pair this component uses is measured for both brands in light and dark on the Accessibility page.

Also in Data display: Data table, Pagination, Status badge, Tag, Avatar, Progress, Chart, Tooltip, Empty state, Skeleton, Spinner. Used in the patterns Dashboard.

Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).