メインコンテンツまでスキップ

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​

StorybookでSimpleを開く

With Up Trend​

StorybookでWith Up Trendを開く

With Down Trend​

StorybookでWith Down Trendを開く

With Help Text​

StorybookでWith Help Textを開く

Sizes​

StorybookでSmallを開く
StorybookでLargeを開く

Centered​

StorybookでCenteredを開く

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.

StorybookでTruncatedを開く

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.

StorybookでWith Leadingを開く

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​