Statistic

A key number with its label and how it changed, like the numbers across the top of a dashboard.

import { Statistic } from '@halo-ds/react';

When to use it

Put a Statistic in a Card, or use it on its own in a row. Trend picks the arrow and the colour of the change badge. Up is green and down is red; for numbers where down is good, like churn, set the badge to Success.

Do

  • Say what the number measures in a short label.
  • Compare with a clear period, like vs last month.
  • Round big numbers so they read at a glance, like 12.4K.
  • Set the Badge to Success when down is good, like churn.

Don't

  • Show more than four or five in one row.
  • Rely on colour alone; keep the arrow and the plus or minus sign.
  • Mix sizes in the same row.
  • Use it for numbers people edit; use an Input.

Props

Statistic props

PropTypeWhat it does
label (required)ReactNodeWhat the number measures, like "Active users". Figma: Label.
value (required)ReactNodeThe number. Numbers are formatted for the reader's language, like 12,480. Figma: Value.
precision`number \undefined`Decimal places for numeric values.
prefixReactNodeBefore the value, like "
quot; or "₦".
suffixReactNodeAfter the value, like "%" or "/ month".
iconReactNodeIcon before the label. Figma: L icon.
changeReactNodeThe change, like "+12.4%". Shown in a badge. Figma: Change.
trend`StatisticTrend \undefined`Direction of the change. Picks the arrow. Figma: Trend.
sentiment`StatisticSentiment \undefined`Whether the change is good or bad, which picks the colour. Defaults to up is good and down is bad. Set it when that's reversed, like churn going up.
comparisonReactNodeWhat the change compares with, like "vs last month". Figma: Comparison.
size`"sm" \"md" \"lg" \undefined`Figma: Size.
loading`boolean \undefined`Shows placeholders while the number loads.
classNames`Partial<Record<StatisticPart, string>> \undefined`Extra class names for the parts inside the component, by part name, like { header: 'my-header' }.
styles`Partial<Record<StatisticPart, CSSProperties>> \undefined`Inline styles for the parts inside the component, by part name, like { footer: { gap: 4 } }.

It also takes the usual HTML attributes for its element.

Examples

Overview

import { Card, Statistic } from '@halo-ds/react';

export default function Example() {
  return (
    <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(180px, 1fr))', gap: 16, width: '100%' }}>
      <Card><Statistic label="Active users" value={12480} change="+12.4%" trend="up" comparison="vs last month" /></Card>
      <Card><Statistic label="Revenue" value={48920} prefix="
quot; change="+5.6%" trend="up" comparison="vs last month" /></Card> <Card><Statistic label="Churn" value={2.3} precision={1} suffix="%" change="-0.4%" trend="down" sentiment="positive" comparison="vs last month" /></Card> </div> ); }

Sizes

Small for dense panels, medium for most dashboards, large for one headline number.

import { Statistic } from '@halo-ds/react';

export default function Demo() {
  return (
    <div className="demo-row" style={{ gap: 40, alignItems: 'flex-start' }}>
      <Statistic size="sm" label="Small" value={12480} change="+12.4%" trend="up" comparison="vs last month" />
      <Statistic size="md" label="Medium" value={12480} change="+12.4%" trend="up" comparison="vs last month" />
      <Statistic size="lg" label="Large" value={12480} change="+12.4%" trend="up" comparison="vs last month" />
    </div>
  );
}

Trends

Up, down and no change. Churn going down is good news, so it uses sentiment="positive".

import { Statistic } from '@halo-ds/react';

export default function Demo() {
  return (
    <div className="demo-grid-2">
      <Statistic label="Revenue" value={48920} prefix="
quot; change="+5.6%" trend="up" comparison="vs last month" /> <Statistic label="Orders" value={312} change="-3.2%" trend="down" comparison="vs last month" /> <Statistic label="Churn rate" value={2.3} precision={1} suffix="%" change="-0.4%" trend="down" sentiment="positive" comparison="vs last month" /> <Statistic label="Seats" value={24} change="0%" trend="flat" comparison="vs last month" /> </div> ); }

Loading

A placeholder while the number loads.

import { Statistic } from '@halo-ds/react';

export default function Demo() {
  return <Statistic label="Active users" value={0} loading />;
}

More: https://halodesignsystem.dev/components/statistic