Aller au contenu principal

Stat

Every example on this page is live, drawn by the library's Storybook, where you can also change its props and see the result.

Displays a large metric with optional trend indicator and help text.

Import​

import { Stat, statTileHeight } from "~lib/data-display/stat";

Props​

NameTypeRequiredDefaultDescription
labelstringYesN/AMetric label
valuestring | numberYesN/AMain display value
change{ value: number; trend: "up" | "down" | "neutral" }NoN/ATrend indicator
helpTextstringNoN/AExplanatory text below
leadingReactNodeNoN/ADrawn before the tile, centered on the value's line
size"sm" | "md" | "lg"No"md"Text size of the tile
align"left" | "center" | "right"NoInheritedText alignment
truncatebooleanNofalseKeep each line to one, ending in "…"

Examples​

Simple​

Ouvrir Simple dans Storybook

With Up Trend​

Ouvrir With Up Trend dans Storybook

With Down Trend​

Ouvrir With Down Trend dans Storybook

With Help Text​

Ouvrir With Help Text dans Storybook

Sizes​

Ouvrir Small dans Storybook
Ouvrir Large dans Storybook

Centered​

Ouvrir Centered dans Storybook

Truncated​

With truncate, a label or value too long for the tile ends in "…" rather than wrapping, so tiles in a row stay the same height.

Ouvrir Truncated dans Storybook

With Leading​

A node such as a coin's Avatar crest sits before the tile's lines, centered on the value. The node and the lines are aligned as one block, so a centered tile centers the pair.

Ouvrir With Leading dans Storybook

Height​

statTileHeight(size, { change, helpText }) returns how tall a tile with every line kept to one is, in pixels, on the frame's own type scale, so a plan can budget a row of tiles. See StatGroup.

See Also​