Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Usage Meter

ProNew

How much of an allowance is used: amber and red as the limit nears, a tick where the warning starts, and overage shown as an amount.

Installation

pnpm dlx shadcn@latest add @viewport/usage-meter

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
label*string

What is metered, e.g. "API requests".

—
used*number—
limit*number—
format(value: number) => string

Formats the two numbers, e.g. to add a unit.

(value) => new Intl.NumberFormat().format(value)
warnAtnumber

The share of the limit at which the bar turns to the warning color, and to the danger color.

0.75
dangerAtnumber0.9
hintstring

A note at the end of the row, e.g. "Resets Jan 1".

—
classNamestring—

Accessibility

  • A meter with a value text that includes the state.
  • “Getting close”, “Near the limit” and “Over the limit” are written out.
  • Server component with no client JavaScript.
  • Respects prefers-reduced-motion.