Documentation

Stat

A key figure: a label, a value in tabular digits, a hint and a trend said in words.

WebStableData display

Web only — React, from @krizaka/ui/stat. Stable: its API only changes in a major version.

When to use

  • On a dashboard: revenue, views, supporters.
  • In a row of a few figures that compare over the same period.

When not to use

  • For figures inside an item's card.Use instead: Card
  • For progress towards a goal.Use instead: Progress
  • For a status.Use instead: Badge

Installation

Install

npm install @krizaka/ui@beta @krizaka/tailwind@beta @krizaka/tokens@beta tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Import

import { Stat } from "@krizaka/ui/stat";

Examples

Up

A rise, with its period.

Revenue

€4,812

+12 %vs last month

Down

A fall, said in words next to the arrow.

Revenue

€4,812

−4 %vs last month

Flat

No change.

Revenue

€4,812

0 %vs last month

Plain

Label and value only.

Revenue

€4,812

Row

A row of stats, as a dashboard shows them.

Views

12.4k

+8 %7 days

Supporters

318

+217 days

Payouts

€902

−3 %7 days

Props

PropTypeDefaultDescription
labelrequiredReactNode—What the figure is ("Revenue"), above it.
valuerequiredReactNode—The figure, formatted by the app, in tabular digits.
hintReactNode—A line under the value: the period, the comparison.
trendStatTrend—The direction of the change; its arrow is decorative.
trendLabelReactNode—The change, in words, as read and shown (e.g. "+12 % vs last week") — the arrow alone says nothing.

Accessibility

  • The arrow is decorative; trendLabel is read and shown.
  • Colour is never the only signal of the trend.

Best practices

  • Format the value in the app (currency, compact numbers) with @krizaka/intl.
  • Say the change in trendLabel (“+12 %”) and the period in hint: the arrow alone says nothing.

Generated from the code of @krizaka/ui 2.0.0-beta.6: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page