Credits, tokens or spend against a plan: a stacked bar by category, agent or model, plan limits, a daily sparkline and when it resets. Point it at a run and it follows the spend live.
Examples
Installation
Installation is part of Pro
Pro components install from a licensed registry. The live preview stays open to everyone.
Props
- title / plan
ReactNode- Default
"Usage" / - - Heading (names the region and the meter) and a plan badge next to it.
- total
number|null- The cycle's budget. Leave out for unlimited: the bar shows the breakdown only and the status says Unlimited.
- used
number- Default
sum of segments - Used so far, if it differs from the sum of the segments.
- segments
{ id, label, value, color?, icon? }[]- The used amount split up. Colours default to the agent palette. Legend shows value and % of used; hover, focus or ← → highlight a segment (announced politely).
- run / groupBy
AgentRun / "agent"|"model"- Default
- / "agent" - Derive segments live from a run: Actor.spend per agent (same colours as every other component) or per model provider with its logo. The bar grows smoothly as spend ticks.
- unit / formatValue
"credits"|"tokens"|"usd"|string / (n) => string- Default
"credits" - Any plural noun works ("runs", "GB"). usd uses formatUsd. formatValue formats the number; the unit word is still added.
- warnAt
number- Default
0.8 - Share that switches to warn; limit at 100%. States are spelled out: "92% used · 800 tokens left", "Limit reached". A hairline marks the threshold on the bar.
- resetsAt / now
Date|string|number- "Resets in 9 days", exact date in a tooltip. now fixes the clock for tests.
- limits
{ id, label, used, total?, unit?, formatValue?, detail?, action? }[]- Thin meters for other quotas. No total: "Unlimited" on a striped track. Almost full / Full in words. With a detail or an action the row opens in place (one at a time, 180ms fold): the detail, and one action { label, onAction, workingLabel?, doneLabel? } that runs in the row as an Action Button.
- daily
{ date, value, future? }[]- Bar sparkline with a tooltip per day; days after today are flat stubs.
- period / defaultPeriod / onPeriodChange
"7d"|"30d"|"cycle"- Default
"7d" - Sparkline range (SegmentedControl). 7d / 30d show the last days up to today; cycle shows the whole cycle.
- onUpgrade / upgradeLabel / topUpLabel
(state) => void / string- Default
- / "Upgrade" / "Add credits" - Shows the call to action: quiet Upgrade while ok, a primary Add credits at warn or limit.
- a11y
role=meter- aria-valuetext like "7,420 of 10,000 credits"; the card is a region labelled by its title.
| Prop | Type | Default | Description |
|---|---|---|---|
| title / plan | ReactNode | "Usage" / - | Heading (names the region and the meter) and a plan badge next to it. |
| total | number | null | - | The cycle's budget. Leave out for unlimited: the bar shows the breakdown only and the status says Unlimited. |
| used | number | sum of segments | Used so far, if it differs from the sum of the segments. |
| segments | { id, label, value, color?, icon? }[] | - | The used amount split up. Colours default to the agent palette. Legend shows value and % of used; hover, focus or ← → highlight a segment (announced politely). |
| run / groupBy | AgentRun / "agent" | "model" | - / "agent" | Derive segments live from a run: Actor.spend per agent (same colours as every other component) or per model provider with its logo. The bar grows smoothly as spend ticks. |
| unit / formatValue | "credits" | "tokens" | "usd" | string / (n) => string | "credits" | Any plural noun works ("runs", "GB"). usd uses formatUsd. formatValue formats the number; the unit word is still added. |
| warnAt | number | 0.8 | Share that switches to warn; limit at 100%. States are spelled out: "92% used · 800 tokens left", "Limit reached". A hairline marks the threshold on the bar. |
| resetsAt / now | Date | string | number | - | "Resets in 9 days", exact date in a tooltip. now fixes the clock for tests. |
| limits | { id, label, used, total?, unit?, formatValue?, detail?, action? }[] | - | Thin meters for other quotas. No total: "Unlimited" on a striped track. Almost full / Full in words. With a detail or an action the row opens in place (one at a time, 180ms fold): the detail, and one action { label, onAction, workingLabel?, doneLabel? } that runs in the row as an Action Button. |
| daily | { date, value, future? }[] | - | Bar sparkline with a tooltip per day; days after today are flat stubs. |
| period / defaultPeriod / onPeriodChange | "7d" | "30d" | "cycle" | "7d" | Sparkline range (SegmentedControl). 7d / 30d show the last days up to today; cycle shows the whole cycle. |
| onUpgrade / upgradeLabel / topUpLabel | (state) => void / string | - / "Upgrade" / "Add credits" | Shows the call to action: quiet Upgrade while ok, a primary Add credits at warn or limit. |
| a11y | role=meter | - | aria-valuetext like "7,420 of 10,000 credits"; the card is a region labelled by its title. |
When to use
When to use
- Credits, tokens or spend against a plan limit, broken down by category, agent or model.
- Settings and billing pages, or following one run's spend live.
When not to use
- How full a model's context window is: use Context Window.
- A single live number such as cost so far: use Number Ticker.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Usage Meter to my app and wire it to my own data.
- I need credits, tokens or spend against a plan limit, broken down by category, agent or model. Set that up with the Knowns UI Usage Meter.
- Which Usage Meter props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "usage-meter" }) and search_docs({ query: "usage meter" }). Pro props, full examples and source come back once your license key is in the MCP config.