UI

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 ·

Period

of 10,000 credits

74%

PER DAYAvg 337 / day

Daily values
October 1210
October 2330
October 3290
October 4410
October 5380
October 6280
October 7340
October 8390
October 9300
October 10440
October 11400
October 12320
October 13250
October 14290
October 15330
October 16360
October 17390
October 18310
October 19300
October 20330
October 21427
October 22Not available
October 23Not available
October 24Not available
October 25Not available
October 26Not available
October 27Not available
October 28Not available
October 29Not available
October 30Not available
  • Seats8 of 10
  • Storage3.2 of 5 GB
  • Projects12 of ∞
Loading interactive preview…

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}
/>

of 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.

PropDefaultEffect
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').
showCategoriestrueControls the interactive category legend independently of the meter.
warnAt0.9Fraction 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.

ArgumentType / defaultDescription
showHeaderbooleanDefault: trueShow title, plan, reset date and period controls
showCategoriesbooleanDefault: trueShow the interactive category legend
showHistorybooleanDefault: trueShow daily usage history
showLimitsbooleanDefault: trueShow secondary allowances
showFooterbooleanDefault: trueShow capacity feedback and the contextual action
showPercentagebooleanDefault: trueShow percentage beside the total
variantoutline | soft | ghostDefault: "outline"Card surface; ghost removes the frame and padding for an embedded meter
sizesm | mdDefault: "md"Readout and meter scale
titlestringDefault: "Usage"Card title
planstring—Current plan name
segmentsRequiredUsageSegment[]—Usage by category
limitRequirednumber—Total allowance
unitstringDefault: "credits"Unit of the main allowance
warnAtnumberDefault: 0.9Share that warns
periodsPeriod[]Default: []Period choices; data comes from host
defaultPeriodstring—Initially selected period
dailyDailyUsage[]Default: []Daily usage history
limitsUsageLimit[]Default: []Secondary finite or unlimited allowances
resetAtstring—When allowance renews, ISO timestamp
nowstring—Reference time for deterministic reset countdown
actionstring—Host action for upgrade or top up
actionLabelstringDefault: "Upgrade"Action label with capacity remaining
topUpLabelstringDefault: "Add credits"Action label near or beyond limit
loadingbooleanDefault: falseHost action pending
statusMessagestring—Host request success or error feedback
valueFormatNumberFormat—Number format
localestring—Number and date locale
motionOptionsUsageCardMotionOptions—Optional chart transition overrides; durations are milliseconds
recipestudio | softDefault: "studio"Visual treatment; behavior is identical
motionnone | subtle | expressiveDefault: "subtle"Arc motion; reduced motion wins
dirltr | rtl—Reading direction; omitted inherits
themeUsageCardTheme—Mode, accent and typed theme tokens

The module also exports usageSummary for computing aggregated usage totals and warning status outside the component.

React integration

PropPurpose
periodControlled 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.
presetApplication defaults, overridden by explicit instance arguments.
tokensCSS variables applied after the typed theme.
ref, className, styleApplied to the root <section> element.
Native attributesid, aria-*, data-*, and remaining <section> props forwarded to the root.

Keyboard & accessibility

KeyInteraction
TabMove between period controls, category meter, daily chart, and action.
ArrowLeft, ArrowRightExplore individual categories on the meter or days on the daily chart.
Home, EndJump to the first or last category or day.
EscapeClear the active category or day readout.
Enter, SpaceActivate 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": []
}

On this page