Prodular UI

AI

Usage meterAIPro

Token and credit usage: a segmented bar against a limit, a context window ring that warns near the limit, and a monthly summary strip.

npx prodular-ui add usage-meter

Part of Prodular UI Pro. Preview and read the docs freely, install with a license. See pricing

Token usage

Input, output and cached tokens against the monthly limit. The total turns to a warning at 80%.

Ledger assistant2.91M of 5M tokens
  • Input1.42M
  • Output610K
  • Cached880K

Resets November 1. Cached input is billed at a tenth of the input rate.

Support automation1.78M of 2M tokens
  • Input1.16M
  • Output420K
  • Cached196K

89% used with 10 days left. Replies will pause at the limit.

Context window

The ring fills as the conversation grows and changes color near the limit. Drag the slider. The compact ring explains itself in a tooltip.

75%Context window96.4K of 128KRoom for about 31.6K more tokens.
In a toolbar
75%

Monthly credits

A bar and one summary strip with dividers, not a grid of cards.

October credits

Growth plan, 25,000 credits a month

Used18,42074% of plan
Remaining6,580About 9 days at this rate
Top consumerAgents11,240 credits, 61%
ResetsNov 1In 11 days

Anatomy

<UsageMeter  label="Ledger assistant"  limit={5_000_000}  segments={[    { label: "Input", value: 1_420_000 },    { label: "Output", value: 610_000 },    { label: "Cached", value: 880_000 },  ]}/><ContextWindow used={96_400} max={128_000} />

Guidance

Use it when

  • Show usage where people spend it: the context ring in the composer, the token meter on the feature's settings, credits on the billing page.
  • Split the bar into the segments people pay for differently, such as input, output and cached tokens.
  • Say what happens at the limit in description: replies pause, older turns are summarized, overage is billed.
  • Put the period and reset date next to monthly numbers.

Avoid

  • Percentages without the absolute numbers. Show 1.42M of 5M tokens.
  • Red before the limit is actually reached. Warning starts at warnAt, destructive only when exceeded.
  • A grid of KPI cards for the summary. Use UsageSummary, one strip with dividers.

Rules for AI agents

Published in llms-full.txt and the registry, so coding agents follow them when they build with this component.

  • Pass raw numbers (tokens or credits as integers) and let the component format them. Do not pass preformatted strings to UsageMeter or ContextWindow.
  • Always pass limit to UsageMeter and max to ContextWindow from the real plan or model. Update ContextWindow max when the selected model changes.
  • Use ContextWindow variant="compact" in toolbars and variant="full" in panels. Never hide the ring once the context is above warnAt.
  • Keep tabular-nums on any number you render next to these components so values do not shift as they update.
  • Use chart-1 to chart-5 or muted for segment colors. Never use AI gradient colors for usage, it is not generated content.

API

UsageMeter

PropTypeDefaultDescription
labelReactNodeWhat is being measured.
segments{ label: string; value: number; color?: "chart-1" | ... | "chart-5" | "muted" }[]Parts of the total, in order.
limitnumberThe plan limit. Exposed with data-state ok, warning or exceeded.
warnAtnumber0.8Ratio of the limit where the warning starts.
unit / format / descriptionstring / (n) => string / ReactNode"tokens" / formatTokensUnit label, number formatting and a line under the bar.

ContextWindow

PropTypeDefaultDescription
used / maxnumberTokens in context and the model's window.
variant"compact" | "full""compact"compact is a 16px ring with a tooltip, full shows numbers and a status line.

UsageSummaryItem

PropTypeDefaultDescription
label / value / descriptionReactNodeOne cell of the summary strip.