Skip to content
Haze UI

Usage meter

A plan's allowances as labelled bars, turning to warning near the limit and to destructive at it, with an upgrade button.

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

When to use

  • A billing or settings page shows how much of each plan limit is used
  • Customers should see a limit coming before they hit it

When not to use

  • One task is in progress. Use progress.
  • The numbers are business results, not allowances. Use stat or bar-list.

Installation

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

pnpm dlx shadcn@latest add @haze/usage-meter
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
titlestring"Team plan"Visible title, usually the plan's name.
periodstring"Renews on 1 December"Billing period or renewal date.
meters{ label: string; used: number; limit?: number; unit?: string }[]–Allowances; leave out limit for unlimited.
warnAtnumber0.8Share of a limit from which a meter warns.
upgradeLabelstring"Upgrade plan"Label of the upgrade button.
upgradeHrefstring"#upgrade"Target of the upgrade button; empty hides it.
localestring"en"Locale used to format the numbers.
unlimitedLabelstring"Unlimited"Word shown for a meter with no limit.
headingLevel2 | 3 | 43Level of the title.
classstring–Additional classes on the panel.

Keyboard interactions

Tab
Reach the upgrade button.

Accessibility

  • Each bar is a native progress element named after its allowance, and the exact numbers are written next to it.
  • Nearly used up and used up change the number's color, but the numbers themselves already say how close the limit is.

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 "Usage meter" with `npx shadcn@latest add @haze/usage-meter`. 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 UsageMeter from "@/components/haze/ui/usage-meter.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/usage-meter.md

  • Customize with real content

    Adapt the Haze usage-meter ui for our product. Replace the demo values of these props with our real content: title, period, meters, warnAt, upgradeLabel, upgradeHref, locale, unlimitedLabel, headingLevel, class. Keep the layout, the heading level rules and these accessibility details: Each bar is a native progress element named after its allowance, and the exact numbers are written next to it. Nearly used up and used up change the number's color, but the numbers themselves already say how close the limit is. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using usage-meter, check it fits: use it when a billing or settings page shows how much of each plan limit is used; customers should see a limit coming before they hit it. Avoid it when one task is in progress. use progress.; the numbers are business results, not allowances. use stat or bar-list.. Alternatives: @haze/progress, @haze/stat, @haze/bar-list.

Dependencies

  • @haze/button
  • @haze/progress
  • @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