Data display
Stat
A key figure with its change, for dashboards and summaries. The direction of the change is always in text, never only in colour or an arrow.
import { Stat } from '@reactloom/ui';Examples
KPI cards
invertTone makes a decrease good (churn, costs); zero shows “Unchanged”.
Revenue
$48,200
12.4%vs last month
Churn
2.1%
3%vs last month
Active users
12,904
Unchanged
Updated hourly
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.
Signups
2,710
18%vs previous 8 weeks
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
| Prop | Type | Default |
|---|---|---|
labelrequiredNames the group. | ReactNode | — |
valuerequiredThe figure, already formatted. | ReactNode | — |
deltaChange as a fraction (0.12 = 12 %). | number | — |
deltaFormat | Intl.NumberFormatOptions | percent, 1 decimal |
deltaLabelContext, e.g. “vs last month”. | ReactNode | — |
invertToneA decrease is good. | boolean | false |
description · icon · chartSecondary text, decorative icon, chart slot. | ReactNode | — |
loadingPlaceholder and aria-busy. | boolean | false |
messagesTranslate the direction text. | Partial<{ increase, decrease, unchanged }> | — |
classNames · stylesroot, 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
| Variable | Default |
|---|---|
--pl-stat-bg | var(--pl-color-bg-surface) |
--pl-stat-border-color | var(--pl-color-border-default) |
--pl-stat-negative | var(--pl-color-danger-fg) |
--pl-stat-padding | var(--pl-space-4) |
--pl-stat-positive | var(--pl-color-success-fg) |
--pl-stat-radius | var(--pl-radius-lg) |
--pl-stat-value-size | var(--pl-font-size-3xl) |
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[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.