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.jsonUsage
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
| Prop | Type | Default | Description |
|---|---|---|---|
| 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. |
| loading | boolean | false | Force 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). |
| currency | string | "USD" | ISO 4217 code used to format costs. |
| warnAt | number | 0.8 | Share 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. |
| title | string | "Usage" | Heading and accessible name of the card. |
| locale | string | "en-US" | BCP 47 locale for dates, costs and percentages. |
| labels | Partial<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. |
| className | string | — | 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 }>;
};