Skip to main content
Login

Sign in to access your account

Metric - National Design System

A dashboard tile that pairs a key value with a small trend chart, so the value and its trend read at a glance

Overview

A metric goes inside a card. It holds a large value, a trend row and a small line chart. The trend row shows the change and its comparison period, such as “+24% vs last week”.

Pick another component when:

  • the value has no comparison period: a statistic card, a centered card with nds-card-number
  • the chart is the focus, or it has more than one series: Chart

Markup

Preview
24h Views
29,840

+24% vs last week

<div class="nds-card nds-stroke" data-status="positive"> <div class="nds-card-header"> <div class="nds-card-featured-icon"> <span class="nds-featured-icon nds-circle"> <i class="nds-icon nds-hgi-trade-up" aria-hidden="true"></i> </span> </div> <div class="nds-card-text"> <div class="nds-card-corner"> <button type="button" class="nds-btn nds-subtle nds-ellipsis nds-vertical nds-icon-only"> <span class="nds-label">More options</span> </button> </div> <span class="nds-card-title">24h Views</span> </div> </div> <div class="nds-card-content"> <div class="nds-card-metric"> <div class="nds-card-metric-info"> <span class="nds-card-metric-value">29,840</span> <p class="nds-card-metric-trend"> <i class="nds-icon nds-hgi-trade-up" aria-hidden="true"></i> <strong>+24%</strong> <span class="nds-card-metric-text">vs last week</span> </p> </div> <div class="nds-card-metric-chart"> <div class="nds-chart" data-chart-type="line" data-chart-series='[{"name":"Views","data":[1500,4500,3000,4500,6000,4500,6000,8500,11000,13000,13000,14500,13000,11000,7800,7200,9500,11500,13000,14500,17000,19000,19000,17500,19500,22000,22000,25000,25000,29800]}]' data-chart-labels='["Day 1","Day 2","Day 3","Day 4","Day 5","Day 6","Day 7","Day 8","Day 9","Day 10","Day 11","Day 12","Day 13","Day 14","Day 15","Day 16","Day 17","Day 18","Day 19","Day 20","Day 21","Day 22","Day 23","Day 24","Day 25","Day 26","Day 27","Day 28","Day 29","Day 30"]' data-chart-config='{"height":110,"legend":{"show":false},"xaxis":{"show":false},"yaxis":{"show":false},"line":{"smooth":true,"area":true,"dots":false,"spotlight":22},"grid":{"show":false},"padding":{"top":0,"bottom":0,"left":0,"right":0}}'> </div> </div> </div> </div> <div class="nds-card-actions"> <button type="button" class="nds-btn nds-subtle nds-icon-only" aria-label="Settings"> <i class="hgi hgi-stroke hgi-settings-02" aria-hidden="true"></i> </button> <a href="#" class="nds-btn nds-secondary-outline">View Report</a> </div> </div>

Built-in Features

  • Trend Status Theming

    One data-status on the card colors the trend, the chart line and the header featured icon together.

  • Inline Sparkline

    The metric removes the chart's 200px minimum height, so a short chart fits in the card.

  • Always-LTR Sparklines

    The chart reads from oldest to newest, left to right, on an RTL page too.

  • Dashboard Header

    In a metric card, the title is smaller, the featured icon is SM, the buttons are MD (a corner button stays SM), and a divider sits above the actions. A menu button goes in the header's .nds-card-corner, as in any card.

  • Card Composition

    A metric card is a normal card. Its classes, such as nds-stroke, nds-shadow and nds-color, still set the border, shadow and color.

  • Custom Colors

    --metric-trend-color and --metric-chart-color replace the status colors on one metric.

Best Practices

  • Use metrics on dashboard pages, where people scan several values and their trends.
  • Put a row of metrics in a grid. Set --max-col on the grid to limit how many share a row.
  • Pick the status by meaning, not by the sign of the change. A falling bounce rate is positive.
  • Write the sign in the change: +24%, -32%. The trend icon is hidden from screen readers, so the text must carry the direction.
  • Keep the value short: 50%, SAR 1.2M, 8,420. A long value wraps and pushes the chart down.
  • Give the chart at least 15 to 20 points. A short series does not show a clear trend.
  • List the chart data from oldest to newest.
  • Add an action, such as View Report, that opens the data behind the value.
  • Give every icon-only button a name for screen readers: an aria-label, or the hidden .nds-label of a More button.

API

Classes

Class Inside Effect
nds-card-metric .nds-card-content Holds the value and the chart. The card around it gets the smaller title and the divider above the actions
nds-card-metric-info .nds-card-metric Holds the value and the trend row
nds-card-metric-value .nds-card-metric-info The large value. Its size scales with the screen
nds-card-metric-trend .nds-card-metric-info The trend row: an icon, the change in <strong>, and the comparison period
nds-card-metric-text .nds-card-metric-trend The comparison period, such as “vs last week”
nds-card-metric-chart .nds-card-metric Holds the .nds-chart and keeps it left to right

Data Attributes

Attribute Element Effect
data-status="positive" .nds-card Success colors on the trend, the chart and the featured icon. With .nds-arrow, the arrow points up
data-status="negative" .nds-card Error colors on the same parts. With .nds-arrow, the arrow points down

CSS Custom Properties

Set these on .nds-card-metric. There they win over the colors of data-status.

Property Default Controls
--metric-trend-color var(--text-default) Color of the trend icon and the change
--metric-chart-color var(--colors-primary-600) Color of the chart line and its area

Tokens

It reads these shared tokens. A change to one also changes other components: see Tokens.

Source: the var() reads in _sass/components/_metric.scss.

TokenPreviewValue
--background-success
Read by --featuredicon-dark-bg
var(--colors-green-600)
--background-error
Read by --featuredicon-dark-bg
var(--colors-red-600)
--text-default
Read by --metric-trend-color

var(--colors-base-black)
Dark mode var(--colors-neutral-200)
--text-display
Read by color

var(--colors-neutral-800)
Dark mode var(--colors-neutral-100)
--text-secondary-paragraph
Read by color

var(--colors-neutral-500)
Dark mode var(--colors-neutral-400)
--text-success
Read by --metric-trend-color

var(--colors-green-700)
Dark mode var(--colors-green-400)
--text-error
Read by --metric-trend-color

var(--colors-red-700)
Dark mode var(--colors-red-400)
--border-success
Read by --metric-chart-color

var(--colors-green-700)
Dark mode var(--colors-green-500)
--border-error
Read by --metric-chart-color

var(--colors-red-700)
Dark mode var(--colors-red-500)
--divider-color
Read by border-block-start

var(--colors-alpha-black-10)
Dark mode var(--colors-alpha-white-10)
--featuredicons-icon-success
Read by --featuredicon-color

var(--icon-success)
Dark mode var(--colors-green-400)
--featuredicons-icon-error
Read by --featuredicon-color

var(--icon-error)
Dark mode var(--colors-red-400)
--featuredicons-background-error-light
Read by --featuredicon-bg

var(--background-error-light)
Dark mode var(--colors-red-alpha-10)
--featuredicons-background-success-light
Read by --featuredicon-bg

var(--background-success-light)
Dark mode var(--colors-green-alpha-10)

JavaScript

Metric has no script. The sparkline is a Chart, and its data-chart-* attributes are documented there.

Last Modified Date: 05/11/2026 - 12:02 PM
Was this page useful?
60% of users said Yes from 2843 Feedbacks