Stat Card

One figure on a dashboard: a title, a 32 px navy figure, and either a sparkline of recent values or the change against the last period. Each direction has its own arrow; a good change is green and a bad one red, where better says which way is good.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { StatCard } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Pipeline value

Open opportunities

$184,250

Props

title
subtitle
value
rate

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoSet better="down" on a delta where a fall is good news, like days to convert, so a drop shows green and not red.
DoGive a delta a label, like "vs prev period", so the reader knows what the change is measured against.
DoLine stat cards up in a row of equal height. The figure and what's under it sit on the card's bottom edge, so the figures line up whatever the titles.
DoShow either a trend or a delta, so the figure stays the strongest thing on the card.
Don'tMove the figure up under its title with a class. In a row of cards with different titles, the figures would sit at different heights.
Don'tUse it for a figure the user picks to filter by, like a pipeline stage. Use CardButton with CardLabel and CardValue.

Props

PropTypeDefaultDescription
title *ReactNode—What's counted, like "New opportunities".
subtitleReactNode—A muted line under the title, like "Share of closed opportunities".
value *ReactNode—The figure, formatted, like "148" or "31%". Text or a number rolls its digits when it changes.
rateReactNode—A rate beside the figure, like "12 / month".
trendunknown—Recent values, oldest first, drawn as a sparkline under the figure.
delta{ /** The change, formatted, like "4.2%". */ value: string; /** Whether it went up or down, shown by its own arrow and read out. */ direction: "up" | "down"; /** Which way is good, like "down" for days to convert. A good change is green, a bad one red. */ better?: "up" | "down"; /** What it's compared with, like "vs prev period". */ label?: string; }—The change against the previous period, under the figure.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

import { StatCard } from "@leap-crm/design-system";

<StatCard
  title="Pipeline value"
  subtitle="Open opportunities"
  value="$184,250"
/>

Sparkline and delta

New opportunities

148

12 / month

Converted to matters

Share of closed opportunities

31%

Up 4.2%vs prev period

Average days to convert

23

Down 3 daysvs prev period

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { StatCard } from "@leap-crm/design-system";

const monthly = [3, 6, 4, 8, 7, 11, 10, 13, 12, 16, 14, 18] as const;