Settings & Usage

Usage Summary

Tokens and cost over time, split by model, against a monthly budget.

3 variantsMIT

Preview

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest add https://uilab.tmih06.com/r/usage-summary.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { UsageSummary } from "@/components/ui/usage-summary";

export function Billing({ report }: { report: UsageReport }) {
  return (
    <UsageSummary
      data={{
        models: [
          { id: "opus", name: "Claude Opus 5.5" },
          { id: "sonnet", name: "Claude Sonnet 5.5" },
        ],
        // One entry per day: { date: "2026-11-03", byModel: { opus: { tokens, cost } } }
        days: report.days,
        previousCost: report.previousPeriodCost,
        budget: { limit: 500, label: "Monthly budget" },
      }}
      currency="USD"
      onSelectDay={(day) => router.push(`/usage/${day.date}`)}
    />
  );
}

// Pass null while the report request is in flight; keep stale data and set
// loading when refetching.
export function BillingState({ query }: { query: UsageQuery }) {
  return (
    <UsageSummary
      data={query.data ?? null}
      loading={query.isRefetching}
      skeleton={{ count: 7, models: 2, budget: true }}
    />
  );
}

Props

PropTypeDefaultDescription
data*{ days: UsageDay[]; models: UsageModel[]; previousCost?: number; budget?: { limit: number; label?: string } } | null—One entry per day with tokens and cost per model. previousCost adds a delta pill; budget adds a budget bar. Pass null while the report loads.
loadingbooleanfalseForce the layout-preserving skeleton while refetching, even when stale data is available.
skeleton{ count?: number; models?: number; budget?: boolean }—Shape hints for the loading state: count day bars, models model rows, and whether to reserve the budget footer (defaults to the stale budget's presence, or true before data has loaded).
currencystring"USD"ISO 4217 code used to format costs.
warnAtnumber0.8Share of the budget past which the budget bar turns into a warning.
onSelectDay(day: UsageDay) => void—Called when a bar is clicked or activated with Enter / Space.
titlestring"Usage"Heading and accessible name of the card.
localestring"en-US"BCP 47 locale for dates, costs and percentages.
labelsPartial<UsageSummaryLabels>—Your own UI strings (loading, subtitle, budget states, screen-reader text), for translating. Right-to-left works under `dir="rtl"`; the days still run left to right.
classNamestring—Extra classes for the root element.
type UsageModel = {
  id: string;
  name: string;
  color?: string; // any CSS color; defaults to the built-in palette
};

type UsageDay = {
  date: string; // ISO date, e.g. "2026-11-03"
  byModel: Record<string, { tokens: number; cost: number }>;
};