Examples

KPI cards

invertTone makes a decrease good (churn, costs); zero shows “Unchanged”.

Preview

Revenue

$48,200

Increased by 12.4%vs last month

Churn

2.1%

Decreased by 3%vs last month

Active users

12,904

Unchanged

Updated hourly

Example.tsx
import { SimpleGrid, Stat } from '@reactloom/ui';
import { DollarSign, UserMinus, Users } from 'lucide-react';

export default function Example() {
  return (
    <SimpleGrid minChildWidth="12rem" gap="4" style={{ width: '100%' }}>
      <Stat icon={<DollarSign />} label="Revenue" value="$48,200" delta={0.124} deltaLabel="vs last month" />
      <Stat icon={<UserMinus />} label="Churn" value="2.1%" delta={-0.03} invertTone deltaLabel="vs last month" />
      <Stat icon={<Users />} label="Active users" value="12,904" delta={0} description="Updated hourly" />
    </SimpleGrid>
  );
}

With a sparkline

Put a chart in the chart slot; the Sparkline has its own accessible summary.

Preview

Signups

2,710

Increased by 18%vs previous 8 weeks

Example.tsx
import { Sparkline } from '@reactloom/charts';
import { Stat } from '@reactloom/ui';

const weekly = [12, 15, 14, 18, 21, 19, 24, 27];

export default function Example() {
  return (
    <div style={{ width: '100%', maxWidth: 280 }}>
      <Stat
        label="Signups"
        value="2,710"
        delta={0.18}
        deltaLabel="vs previous 8 weeks"
        chart={<Sparkline data={weekly} label="Signups per week, last 8 weeks" type="area" width={240} />}
      />
    </div>
  );
}

API reference

Stat props
PropTypeDefault
labelrequired
Names the group.
ReactNode—
valuerequired
The figure, already formatted.
ReactNode—
delta
Change as a fraction (0.12 = 12 %).
number—
deltaFormat
Intl.NumberFormatOptionspercent, 1 decimal
deltaLabel
Context, e.g. “vs last month”.
ReactNode—
invertTone
A decrease is good.
booleanfalse
description · icon · chart
Secondary text, decorative icon, chart slot.
ReactNode—
loading
Placeholder and aria-busy.
booleanfalse
messages
Translate the direction text.
Partial<{ increase, decrease, unchanged }>—
classNames · styles
root, header, icon, label, value, delta, description, chart.
Partial<Record<StatSlot, …>>—

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

Slot class names

Add classes to inner parts with classNames (className is shorthand for root): root, header, icon, label, value, delta, description, chart.

CSS variables

VariableDefault
--pl-stat-bgvar(--pl-color-bg-surface)
--pl-stat-border-colorvar(--pl-color-border-default)
--pl-stat-negativevar(--pl-color-danger-fg)
--pl-stat-paddingvar(--pl-space-4)
--pl-stat-positivevar(--pl-color-success-fg)
--pl-stat-radiusvar(--pl-radius-lg)
--pl-stat-value-sizevar(--pl-font-size-3xl)

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-tone]present when on

Theme tokens it reads

--pl-color-bg-surface --pl-color-border-default --pl-color-danger-fg --pl-color-fg-default --pl-color-fg-muted --pl-color-success-fg --pl-font-size-3xl --pl-font-size-sm --pl-radius-lg

Accessibility

  • A group named by the label, so “Revenue” introduces the figures that follow.
  • The change is read as “Increased by 12.4%”: the arrow and colour are decorative.

Usage guidelines

Do

  • Pair the figure with a comparison period.
  • Use invertTone for metrics where lower is better.

Don’t

  • Don’t rely on colour to show whether a change is good.