Data display
Stat
Free14.3 KB gzippedA big, bold number with a label, for dashboards and box scores: points, revenue, completion rates. Optional trend, progress, icon, and sparkline.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report
Import
import { Stat, StatGroup } from "@vjdesigns/vjdesigns-ui";
Importing only Stat adds about 14.3 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
change shows a trend with an arrow and a sign, so it never relies on color alone.
- Monthly revenue
- $48,200, increased by 12.4% vs last month
import { Stat } from "@vjdesigns/vjdesigns-ui";
export function Basic() {
return (
<Stat
label="Monthly revenue"
value={48200}
format={{ style: "currency", currency: "USD", maximumFractionDigits: 0 }}
change={0.124}
comparisonLabel="vs last month"
size="lg"
/>
);
}
Group
StatGroup lays out related stats as a description list.
- Active users
- 2,481, increased by 8%
- Churn
- 2.1%, increased by 0.4%
- Avg. session
- 6.4min, decreased by 3%
import { Stat, StatGroup, UsersIcon } from "@vjdesigns/vjdesigns-ui";
export function Group() {
return (
<div style={{ width: "100%" }}>
<StatGroup columns={{ base: 1, md: 3 }} variant="card" divided>
<Stat label="Active users" value={2481} change={0.08} icon={<UsersIcon />} />
<Stat label="Churn" value={0.021} format={{ style: "percent", maximumFractionDigits: 1 }} change={0.004} positiveIsGood={false} />
<Stat label="Avg. session" value={6.4} unit="min" change={-0.03} />
</StatGroup>
</div>
);
}
With progress
progress adds a bar toward a goal; variant="accent" adds a colored edge.
import { Stat } from "@vjdesigns/vjdesigns-ui";
export function WithProgress() {
return (
<div style={{ width: "100%", maxWidth: "20rem" }}>
<Stat
variant="accent"
label="Fundraising"
value={36500}
format={{ style: "currency", currency: "USD", maximumFractionDigits: 0 }}
progress={{ value: 36500, max: 50000, label: "Goal: $50,000", showValue: true }}
/>
</div>
);
}
Accessibility
The change isn't just an arrow and a color: screen readers hear a generated sentence with the direction, the amount and the comparison. positiveIsGood={false} makes a rise in tickets read as bad news, and animate counts up visually while screen readers always get the final value (and reduced-motion users skip the animation).
- Revenue
- $48,200, increased by 12.4% vs last month
- Support tickets
- 312, increased by 8% vs last month
import { Stat, StatGroup } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<StatGroup columns={{ base: 1, sm: 2 }} variant="card">
<Stat
label="Revenue"
value={48200}
format={{ style: "currency", currency: "USD", maximumFractionDigits: 0 }}
change={0.124}
comparisonLabel="vs last month"
animate
/>
<Stat label="Support tickets" value={312} change={0.08} positiveIsGood={false} comparisonLabel="vs last month" />
</StatGroup>
);
}
Translated
Currency, percentages and the generated change sentence follow the locale: German shows 48.200 € and 3,4 %.
- Umsatz
- 48.200 €, um 12,4 % gestiegen ggü. Vormonat
- Konversionsrate
- 3,4 %, um 2 % gesunken
import { Stat, StatGroup, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import de from "@vjdesigns/vjdesigns-ui/locales/de";
export function Translated() {
return (
<LocaleProvider locale="de" messages={de}>
<StatGroup columns={{ base: 1, sm: 2 }} variant="card">
<Stat
label="Umsatz"
value={48200}
format={{ style: "currency", currency: "EUR", maximumFractionDigits: 0 }}
change={0.124}
comparisonLabel="ggü. Vormonat"
/>
<Stat label="Konversionsrate" value={0.034} format={{ style: "percent", maximumFractionDigits: 1 }} change={-0.02} />
</StatGroup>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Basic
- Monthly revenue
- 48,200 US$, زاد بمقدار 12.4% vs last month
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
<Basic />
</LocaleProvider>
Usage notes
Semantics: a description list. Standalone, the root is a <dl>; inside a StatGroup (itself a <dl>), the root is a <div> grouping one <dt> (the label) with its <dd>s (value and change, help text, progress, sparkline). Screen readers read it as "Points: 24.3, increased by 4.2% from last week". Trends are never color- or arrow-only: the sign is in the visible text and the direction is spelled out in hidden text.
API reference
Stat
| Prop | Type | Default |
|---|---|---|
labelRequiredEyebrow label above the value, shown in uppercase display type (e.g. | ReactNode | — |
valueRequiredThe headline value. Numbers are formatted with | ReactNode | — |
format
| Intl.NumberFormatOptions | — |
localeLocale(s) for number formatting. | string | string[] | the user's locale |
prefixText before the value, at a smaller size (e.g. | ReactNode | — |
suffixText right after the value, at a smaller size (e.g. | ReactNode | — |
unitUnit after the value in small caps type, e.g. | ReactNode | — |
helpTextMuted supporting text under the value, e.g. | ReactNode | — |
iconDecorative icon next to the label, in a soft tone-tinted circle. Hidden from assistive technology. | ReactNode | — |
sizeType and spacing scale. | "sm""md""lg""xl" | "md" |
alignHorizontal alignment. | "start""center""end" | "start" |
variantSurface style. | "plain""card""accent" | "plain" |
accentPositionEdge the | "start""top" | "start" |
toneTints the icon circle, the accent bar, and the progress fill. | "neutral""primary""accent""success""warning""danger""info" | "primary" for the icon and progress; the accent bar defaults to `"accent"` |
changeChange since the comparison period, formatted with | number | — |
changeTypeDirection of the change. | "increase""decrease""neutral" | inferred from the sign of `change` |
positiveIsGoodWhether an increase is good news. Set | boolean | true |
changeFormat
| Intl.NumberFormatOptions | { style: "percent", maximumFractionDigits: 1 } |
comparisonLabelThe comparison period, appended to the screen-reader change text, e.g. | string | — |
changeLabelReplaces the whole generated screen-reader change text. | string | — |
progressThin progress bar under the value, e.g. toward a season goal. | StatProgress | — |
sparklineSlot for a small chart (e.g. a sparkline), shown beside the value. Give it its own text alternative. | ReactNode | — |
animateCounts a numeric | boolean | false |
loadingShows placeholder blocks instead of the value and change, and sets | boolean | false |
loadingLabelScreen-reader text while | string | "Loading" |
Also accepts native <div> attributes, plus className, style and ref.
StatGroup
A responsive row or grid of Stats, such as a player's box-score line. Renders one <dl>, so the whole group is a single description list.
With divided, stats sit edge to edge with hairline dividers; give the stats variant="plain" there (a card stat's shadow would be clipped).
| Prop | Type | Default |
|---|---|---|
children
| ReactNode | — |
columnsNumber of columns, fixed or per breakpoint (mobile first), e.g. | Responsive<number> | — |
dividedDraws hairline dividers between stats, across wrapped rows too. | boolean | false |
variantSurface style. | "plain""card" | "plain" |
Also accepts native <dl> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Stat targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10038 passed · 0 failed · 27 not applicable · 10 to check by hand
Dark mode
Score 10038 passed · 0 failed · 27 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
Not focusable, so there's no keyboard interaction of its own.
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Label and value | term and definition | <dl> / <dt> / <dd> |
| Change indicator | none | Arrow aria-hidden; direction spoken as text |
progress | progressbar | aria-valuenow, aria-valuemin, aria-valuemax |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |