Skip to content
Haze UI

Stat

One metric with a small label, a large tabular value and an optional change with a trend arrow; plain or in a card panel.

pnpm dlx shadcn@latest add @haze/stat
Open preview in a new tab
Liveno JavaScript

When to use

  • A dashboard row of headline numbers such as revenue, signups or error rate
  • Showing how a number moved since the last period
  • A number inside a card header or a hero strip that needs a label and context

When not to use

  • A number that is part of a sentence; write it in the text
  • A full chart or a history of values; stat shows one value and one change

Installation

Add the Haze registry to components.json once, then install Stat with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/stat
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
label*string–What is measured, shown as a small uppercase label above the value.
value*string–The number, already formatted, for example "$48,200".
changestring–Change since the comparison period, for example "+12.4%".
trend"up" | "down" | "neutral""neutral"Direction of the change. Picks the arrow icon, and the color unless tone is set.
tone"positive" | "negative" | "neutral"–Whether the change is good news: success, destructive or muted color. Defaults to positive for up, negative for down and neutral for neutral. Set it when up is bad, such as a rising refund rate.
trendLabelstring–Screen-reader text read before the change. Overrides the three words below.
increaseLabelstring"Increased by"Screen-reader text for an upward change. Translate it for other languages.
decreaseLabelstring"Decreased by"Screen-reader text for a downward change. Translate it for other languages.
unchangedLabelstring"No change"Screen-reader text for no change. Translate it for other languages.
descriptionstring–Comparison note after the change, for example "vs. last month".
variant"plain" | "card""plain"plain has no frame; card draws a bordered panel with padding.
icon(props) => unknown–A lucide icon component shown at the right of the label. Decorative.
classstring–Extra classes on the wrapper.

Accessibility

  • The direction is spoken through the sr-only trendLabel, so "+12.4%" is announced as "Increased by 12.4%" and not as a bare number. One leading +, - or minus sign is dropped from the spoken text only, so a fall reads "Decreased by 0.3%".
  • Up and down also differ by arrow direction, not only green and red. The icons are aria-hidden.
  • Direction and meaning are separate: trend sets the arrow and the spoken word, tone sets the color. A rising refund rate is trend="up" tone="negative"; the spoken text still says it increased.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Stat" with `npx shadcn@latest add @haze/stat`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Stat from "@/components/haze/ui/stat.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/stat.md

  • Customize with real content

    Adapt the Haze stat ui for our product. Replace the demo values of these props with our real content: label, value, change, trend, tone, trendLabel, increaseLabel, decreaseLabel, unchangedLabel, description, variant, icon, class. Keep the layout, the heading level rules and these accessibility details: The direction is spoken through the sr-only trendLabel, so "+12.4%" is announced as "Increased by 12.4%" and not as a bare number. One leading +, - or minus sign is dropped from the spoken text only, so a fall reads "Decreased by 0.3%". Up and down also differ by arrow direction, not only green and red. The icons are aria-hidden. Direction and meaning are separate: trend sets the arrow and the spoken word, tone sets the color. A rising refund rate is trend="up" tone="negative"; the spoken text still says it increased. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using stat, check it fits: use it when a dashboard row of headline numbers such as revenue, signups or error rate; showing how a number moved since the last period; a number inside a card header or a hero strip that needs a label and context. Avoid it when a number that is part of a sentence; write it in the text; a full chart or a history of values; stat shows one value and one change. Alternatives: @haze/card, @haze/progress, @haze/tag.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog