Skip to content
Eskais UI

Data

Stat

Summary figures: Stat, StatLabel, StatValue (a number, a Quantity or a node), StatHint, StatDelta (a change with its direction in words) and StatMedia (an icon in a tone chip at the end), in a responsive StatGroup list.

Example

  • Done
    12
    up 20% vs. last week
  • Cost
    $4.20 (estimated)
    down 8% vs. last week
  • Duration
    unknown
    Not reported

Installation

npx shadcn@latest add @eskais/stat
Brings alongtonequantitylocale
npm packagesclass-variance-authority@0.7.1lucide-react

Usage

Import
import {  Stat,  StatDelta,  statDeltaLabels,  StatGroup,  StatHint,  StatLabel,  StatMedia,  StatValue,} from "@/components/ui/stat"import { StatDelta, statDeltaLabels } from "@/components/ui/stat-delta"

For a KPI card, put a StatMedia with an icon and a tone among the parts; the Stat lays it out at the end, beside the label, value and hint.

API reference

StatMedia

PropTypeDefault
toneThe chip's soft fill and the colour of the icon on it. Default `neutral`.Tone"neutral"
labelNames what the media shows (`role="img"`); without it the chip is decorative and hidden from assistive technology.string–

Also takes <div> attributes and render.

StatValue

PropTypeDefault
valuenumber | Quantity–

Also takes <div> attributes and render, FormatQuantityOptions.

StatGroup

PropTypeDefault
childrenReactNode–

Also takes <ul> attributes and render except children.

StatDelta

PropTypeDefault
valuerequiredThe change, as a ratio by default: 0.12 reads "12%". Its sign gives the direction.number–
directionOverrides the direction the sign gives, as for a value that rounds to zero."up" | "down" | "flat"–
invertFor a metric where down is good, like cost or errors: down reads success and up destructive.booleanfalse
toneOverrides the tone the direction gives.Tone–
comparisonWhat the change is measured against, like "vs. last week"; shown after the change, and read with it.ReactNode–
format`Intl.NumberFormat` options for the change's size (a percent by default), or a function of it.Intl.NumberFormatOptions | ((value: number) => string)percent
localestring–
labelsPartial<StatDeltaLabels>–

Also takes <span> attributes and render except children.

Other exports

StatstatDeltaLabelsStatHintStatLabeltype StatDeltaDirectiontype StatDeltaLabelstype StatDeltaPropstype StatGroupPropstype StatMediaPropstype StatValueProps

Accessibility

  • A labelled group of figures; unknown values show a dash and estimates a tilde, explained in their title.
  • A StatMedia is decorative and hidden unless its label makes it an image with that name.

Agent actions

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.