Usage card
Display plan usage by category, daily activity, secondary limits, and a contextual action.
import { UsageCard } from '@uthereal/ui/usage-card'Usage card playground
Acme AI
Pro plan ·
7,420of 10,000 credits
74%| October 1 | 210 |
|---|---|
| October 2 | 330 |
| October 3 | 290 |
| October 4 | 410 |
| October 5 | 380 |
| October 6 | 280 |
| October 7 | 340 |
| October 8 | 390 |
| October 9 | 300 |
| October 10 | 440 |
| October 11 | 400 |
| October 12 | 320 |
| October 13 | 250 |
| October 14 | 290 |
| October 15 | 330 |
| October 16 | 360 |
| October 17 | 390 |
| October 18 | 310 |
| October 19 | 300 |
| October 20 | 330 |
| October 21 | 427 |
| October 22 | Not available |
| October 23 | Not available |
| October 24 | Not available |
| October 25 | Not available |
| October 26 | Not available |
| October 27 | Not available |
| October 28 | Not available |
| October 29 | Not available |
| October 30 | Not available |
- Seats8 of 10
- Storage3.2 of 5 GB
- Projects12 of ∞
Overview
UsageCard tracks a workspace or plan allowance across stacked categories, optional daily history bars, secondary limits, and a contextual upgrade or top-up action. Disable the surrounding sections and switch to variant="ghost" to embed the same component as a bare allowance meter.
Use UsageCard for subscription quotas, storage budgets, and credit consumption. For an AI model's prompt token budget, use Context window.
Usage
'use client'
import { useState } from 'react'
import { UsageCard } from '@uthereal/ui/usage-card'
export function WorkspaceUsage() {
const [period, setPeriod] = useState('30d')
return (
<UsageCard
title="Workspace usage"
plan="Pro"
unit="credits"
limit={100}
segments={[
{ id: 'chat', label: 'Chat', value: 52 },
{ id: 'search', label: 'Search', value: 22 },
]}
periods={[
{ id: '7d', label: '7d' },
{ id: '30d', label: '30d' },
]}
period={period}
onPeriodChange={setPeriod}
action="open_billing"
onAction={(action) => console.log(action)}
/>
)
}onPeriodChange reports the selected period ID so your application can supply the matching segments, daily values, and limits from its cache. onAction receives the configured action name when the footer button is activated; the card never fetches or mutates billing state.
Examples
Embedded meter
Hide the card frame and surrounding sections to render a compact inline meter that retains full keyboard exploration and accessible naming.
<UsageCard
title="Workspace storage"
unit="GB"
limit={15}
segments={[
{ id: 'docs', label: 'Documents', value: 7.2 },
{ id: 'photos', label: 'Photos', value: 5.2 },
]}
variant="ghost"
size="sm"
showHeader={false}
showHistory={false}
showLimits={false}
showFooter={false}
showPercentage={false}
/>12.4of 15 GB
Sections and host data
All section visibility flags default to true, though daily history and secondary limits render only when data is provided.
| Prop | Default | Effect |
|---|---|---|
variant | 'outline' | 'outline' draws a bordered card, 'soft' uses a subtle fill, 'ghost' removes the frame. |
size | 'md' | Scales the total readout and meter track ('sm' or 'md'). |
showCategories | true | Controls the interactive category legend independently of the meter. |
warnAt | 0.9 | Fraction between 0.5 and 1 that triggers warning styling and topUpLabel. |
Hover, focus, or press a category row or bar segment to highlight that category and read its exact value. Secondary limits accept a positive number or null for unlimited allowances. Supply resetAt as an ISO timestamp; pair it with now for a deterministic relative countdown, or omit now to format the reset date. Use loading and statusMessage to reflect host action state.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
showHeader | booleanDefault: true | Show title, plan, reset date and period controls |
showCategories | booleanDefault: true | Show the interactive category legend |
showHistory | booleanDefault: true | Show daily usage history |
showLimits | booleanDefault: true | Show secondary allowances |
showFooter | booleanDefault: true | Show capacity feedback and the contextual action |
showPercentage | booleanDefault: true | Show percentage beside the total |
variant | outline | soft | ghostDefault: "outline" | Card surface; ghost removes the frame and padding for an embedded meter |
size | sm | mdDefault: "md" | Readout and meter scale |
title | stringDefault: "Usage" | Card title |
plan | string— | Current plan name |
segmentsRequired | UsageSegment[]— | Usage by category |
limitRequired | number— | Total allowance |
unit | stringDefault: "credits" | Unit of the main allowance |
warnAt | numberDefault: 0.9 | Share that warns |
periods | Period[]Default: [] | Period choices; data comes from host |
defaultPeriod | string— | Initially selected period |
daily | DailyUsage[]Default: [] | Daily usage history |
limits | UsageLimit[]Default: [] | Secondary finite or unlimited allowances |
resetAt | string— | When allowance renews, ISO timestamp |
now | string— | Reference time for deterministic reset countdown |
action | string— | Host action for upgrade or top up |
actionLabel | stringDefault: "Upgrade" | Action label with capacity remaining |
topUpLabel | stringDefault: "Add credits" | Action label near or beyond limit |
loading | booleanDefault: false | Host action pending |
statusMessage | string— | Host request success or error feedback |
valueFormat | NumberFormat— | Number format |
locale | string— | Number and date locale |
motionOptions | UsageCardMotionOptions— | Optional chart transition overrides; durations are milliseconds |
recipe | studio | softDefault: "studio" | Visual treatment; behavior is identical |
motion | none | subtle | expressiveDefault: "subtle" | Arc motion; reduced motion wins |
dir | ltr | rtl— | Reading direction; omitted inherits |
theme | UsageCardTheme— | Mode, accent and typed theme tokens |
The module also exports usageSummary for computing aggregated usage totals and warning status outside the component.
React integration
| Prop | Purpose |
|---|---|
period | Controlled period ID matching an entry in periods. |
onPeriodChange(period) | Called when the user selects a period, in both controlled and uncontrolled mode. |
onAction(action) | Called with the configured action name when the footer action runs. |
preset | Application defaults, overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root. |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Move between period controls, category meter, daily chart, and action. |
ArrowLeft, ArrowRight | Explore individual categories on the meter or days on the daily chart. |
Home, End | Jump to the first or last category or day. |
Escape | Clear the active category or day readout. |
Enter, Space | Activate the focused period choice, category row, or footer action. |
The category bar exposes role="meter" and keeps its accessible name and keyboard exploration even when showHeader or showCategories is false. A visually hidden data table exposes every daily value to assistive technology, and polite role="status" regions announce active readouts and host status updates. Reading direction inherits from the page or follows dir. Under forced-colors, segment boundaries, focus outlines, and text stay high-contrast.
Motion and theming
One animation clock counts totals, category values, and percentages while segment widths track the same progress. The first visible snapshot fills from zero; switching periods retargets smoothly from the displayed values. Removed categories shrink as their rows collapse, and daily bars morph through the chart transition (motionOptions.morph). motion="none" and prefers-reduced-motion: reduce remove spatial animation.
theme accepts a mode, an accent, and token groups for core, control, popupList, and chart, plus surfaceRadius, surfaceSunken, borderStrong, success, warning, danger, fontFamilyDisplay, and shadowResting. An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, UsageCard is a leaf. The host stores the active period ID at /components/instance-<id>/period, seeded from defaultPeriod and reconciled when periods change. action must name a host-registered action; the component never fetches or updates billing state directly. See React and JSON integration.
{
"type": "UsageCard",
"props": {
"title": "Workspace usage",
"limit": 100,
"unit": "credits",
"segments": [{ "id": "chat", "label": "Chat", "value": 74 }],
"action": "open_billing"
},
"children": []
}