Skip to content
SettingsUsage meterMenu

Usage meter

Plan usage with tabular numbers and live reset times: one bar per limit, a warning line, a Limit reached state and an upgrade slot.

Session and weekly limits with live reset times and an upgrade slot.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/usage-meter.json

Usage

tsx
import { UsageMeter, UsageMeterItem } from "@/components/ui/chatcn/usage-meter"

<UsageMeter plan="Pro" action={<Button size="sm" variant="outline">Upgrade</Button>}>
  <UsageMeterItem label="Current session" used={34} limit={45} unit="messages" resetsAt={resetAt} />
  <UsageMeterItem label="Weekly, all models" used={0.41} limit={1} resetsAt={weekly} />
</UsageMeter>

Under a day, the reset reads Resets in 2 h 14 m and ticks down; past a day it shows the wall clock. Without a unit the item shows a percentage.

Examples

States

Normal, warning, exhausted, extra usage on and capped by an admin.

Props

PropTypeNotes
labelReactNode
used, limitnumberPass a fraction with limit={1} for percent-only limits
unitstringmessages, credits. Omit for a percentage
resetsAtnumber | Date | stringLive countdown under a day
resetLabelReactNodeOverride the reset line
warnAtnumberDefault 0.8
overageReactNodeExtra usage is on: the overage as text
adminNoteReactNodeA lock and the note
onReset() => voidOnce, when resetsAt passes

Accessibility

  • Each bar is a meter labelled by its row, with the count or percentage as aria-valuetext.
  • The bar turns amber past the warning line and red at the limit, and Limit reached is a word, so it survives grayscale and forced colors.

Motion

  • Bars grow with a 280 ms transform when usage changes, never a count-up. Reduced motion snaps.
  • The reset label ticks once a minute above an hour and once a second below it.