Stat

A big number followed by its word, no box, or a tile with its label, change and trend. StatGroup lines numbers up in a row or tiles in a grid.

View source
12,480requests
$184.20total spend+12%
1.2 smedian latency
import { Stat, StatGroup } from "@logicplanes/kaeso-ui";

Props

  • change
    { value: number; better?: "none" | "up" | "down"; }

    The change against the previous period, as a fraction (0.12 is +12%). better says which direction is good: errors are better down, and none keeps a number such as cost neutral. It is written as text by Delta: green or red, and "better" or "worse" for screen readers.

  • delta
    { label: string; tone?: "neutral" | "success" | "danger"; }

    A delta badge: "+12%".

  • detail
    ReactNode

    A quiet line under the number: "vs. the previous 30 days", "0.4% of requests".

  • label
    ReactNode

    What the number counts: "Requests", "Cost". A tile sets it at its foot.

  • loading
    boolean

    While the numbers load: the value, the change and the trend show their shape at the tile's final height.

  • size
    "md" | "sm" = md

    The size of the number.

  • trend
    number[]

    One value per day (or step), drawn as a sparkline across the tile. A tile without it has no room for one; pass [] while a trend loads to keep it.

  • trendColor
    string

    The trend's color; the first series color by default.

  • unit
    ReactNode

    The word after it, on the same baseline: "total spend", "sessions".

  • value
    ReactNode

    The number, already formatted: "$12.40", "1.2M".

  • variant
    "plain" | "tile" = grid

    A plain number with its unit and delta, or a tile in a StatGroup with its label, change, detail and trend.