Xzero UI
Pro library

Usage billingPro

A usage based billing dashboard with a projected spend line, meters against limits, alerts, and an upgrade that morphs into a confirm sheet.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/usage-billing
Live · keyboard ready

Use this in the billing area of a usage priced product. Load meters, daily spend, and invoices from your billing provider, save alerts through onAlertsChange, and send the upgrade to your checkout; every charge in the preview is simulated.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/usage-billing

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { UsageBilling } from "@/components/xzero/blocks/usage-billing/usage-billing";

export function BillingPage({ usage, plans }: { usage: BillingSnapshot; plans: PlanCatalog }) {
  return (
    <UsageBilling
      period={usage.period}
      daily={usage.dailySpend}
      meters={usage.meters}
      plan={plans.current}
      upgrade={plans.next}
      defaultAlerts={usage.alerts}
      onAlertsChange={alerts => saveAlerts(alerts)}
      onUpgrade={plan => startUpgrade(plan.id)}
      onDownloadInvoice={invoice => downloadPdf(invoice.id)}
    />
  );
}

API reference

UsageBilling

A usage based billing dashboard: spend so far with a projected line and live alert rules on the chart, per meter usage against limits with warning states, a spend alerts editor, invoice history with downloads, and a plan card that grows into an upgrade confirm sheet.

PropTypeDefaultDescription
period{ label: string; start: string; days: number; today: number }billingPeriodThe current billing period and which day it is.
dailynumber[]dailySpendUsage charges per day so far. Its length is the number of days elapsed.
budgetnumber2000Monthly budget drawn on the chart.
metersMeter[]metersMetered resources: id, name, unit (requests, gigabytes, minutes, invocations, seats), used, limit, and an overage price label.
planPlancurrentPlanThe current plan: name, monthly price, limits keyed by meter id, and perks.
upgradePlan | nullupgradePlanThe plan offered in the upgrade card. Pass null to hide the offer.
defaultAlertsSpendAlert[]spendAlertsInitial alerts: amount, email, and slack.
onAlertsChange(alerts: SpendAlert[]) => void–Called whenever alerts are added, edited, or removed.
invoicesInvoice[]invoicesPast invoices with number, period, issue date, amount, and status.
payment{ brand: string; last4: string; expires: string }paymentMethodCard shown on the plan card, the invoices header, and the confirm sheet.
onUpgrade(plan: Plan) => Promise<void> | void–Runs the upgrade. Resolve to switch plans, reject to show a declined message. Without it the upgrade is simulated.
onDownloadInvoice(invoice: Invoice) => Promise<void> | void–Fetches an invoice PDF. Without it the download is simulated.
currencystring"EUR"ISO currency code for every amount.
classNamestring–Class on the root.

Keyboard interactions

KeysAction
TabMoves through the chart, plan card, alerts, and invoice downloads.
Arrow left / Arrow rightMoves the chart cursor one day at a time while the chart has focus.
Enter in an alert amountCommits the amount; alerts re sort by amount when the field loses focus.
EscapeCloses the upgrade sheet unless a payment is in progress.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Blocks are complete, self-contained screens with sample data. Replace the sample data and connect the callbacks described above. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components