Meter

Free

A value against its limit: one line with its label, a short phrase and the percent over a thin bar that turns orange when the pace runs out first and red at the limit.

npx shadcn@latest add https://pixilui.com/r/meter.json

Preview

A thin bar that turns orange before you run out.
State
Variant

When to use

Use it when

  • Context used in a conversation, seats on a plan, storage, any share of a limit.
  • A compact share in a status bar or a composer footer (variant="inline").

Use something else when

  • Usage windows that reset on a clock: use Usage meter, which writes the phrases for you.
  • Progress of a task toward done: use a progress bar or the run's status.

Installation

Terminal
npx shadcn@latest add https://pixilui.com/r/meter.json

Adds meter.tsx, and installs clsx and tailwind-merge. The URL works in any app with a components.json, with no registry to add first.

Usage

example.tsx
import { Meter } from "@/components/pixilui/meter";

<Meter label={label} value={value} />

Fills its container; the label truncates first, the phrase and percent stay whole.

API reference

PropTypeDefault
labelRequiredstring–The window's name, such as "5-hour limit". It truncates when narrow.
valueRequirednumber–The used share, 0 to 100. The fill stops at 100; the percent shows the rounded value.
state"ok" | "warn" | "limit""ok"ok (the run hue), warn (orange: the pace runs out first) or limit (red, full).
notestring–One short phrase before the percent, such as "Resets 4:14 pm" or "Out by 2:40 pm". Not shown inline.
noteKeystring–What the phrase means. A new meaning cross-fades; the same meaning with new words changes in place (a countdown tick). Defaults to the phrase itself.
variant"card" | "inline""card"card: the line over a 6px bar. inline: label, a 64px bar and the percent, for status bars and composer footers.
drainingbooleanfalseThe share is draining back to zero (a reset): slower, on the in-out curve.

Also takes every native <div> attribute, and a ref.

Keyboard

TabNever takes focus: it reports, it is not a control.

Accessibility

  • A meter named by its whole sentence (description), so the share is never color alone.
  • The phrase changes are visible text; put a live region on the place that should announce them.

Motion

  • The fill follows the value on the out curve; draining back to zero after a reset is slower, on the in-out curve.
  • A phrase with a new meaning cross-fades (the system's swap); the same meaning with new words, like a countdown tick, changes in place.
  • Reduced motion: instant.

PixilUI Pro opens soon. The first 20 licenses are $99.