Skip to content
GitHub (opens in a new tab)
BillingBlock

Usage & billing

Plan usage and what it costs, with the next invoice estimate and past invoices.

What a block is

A block is a kit component for a whole area of a screen, built only from other kit components and tokens. You import it like any component; nothing is copied into your app. Put it inside your page’s <main>: it brings no header or nav of its own.

When to use

  • the billing or usage area of a SaaS settings page
  • show how close an account is to its limits next to the plan that sets them
  • download a recent invoice or change the payment method from one place

When not to use

  • one invoice in full: InvoiceDocument
  • only the allowance meter: UsageMeter
  • choosing between plans: PricingPlans
  • an overdue account that must pay now (Pay now is the primary, not Upgrade): compose Alert, Button and these parts on the page

Usage

The main allowance sits beside the plan, then the next invoice as an estimate beside the other limits, then the latest invoices to download. Upgrade turns solid only once usage reaches the warning line.

import { UsageBilling } from "agentic-ds-kit";

export function Billing({ plan, credits, nextInvoice, limits, invoices }) {
  return (
    <main className="layout-content">
      <UsageBilling
        plan={plan}              // { name, price, priceNote?, nextCharge?, paymentMethod?, upgradeTo?, fit? }
        allowance={credits}      // UsageMeter props: { title, used, limit, unit?, daily?, overage?, … }
        upcoming={nextInvoice}   // InvoiceDocument props, shown as an Estimate
        limits={limits}          // UsageList items: { id, label, used, limit, unit? }[]
        invoices={invoices}      // { id, number, date, amount, status }[], newest first
        onUpgrade={() => openCheckout("scale")}
        onManagePayment={() => openBillingPortal()}
        onDownloadInvoice={(id) => download(id)}
      />
    </main>
  );
}

Layout

  • top: the UsageMeter beside the plan Card, in layout-split--primary
  • with upcoming: the estimate InvoiceDocument beside the other limits Card, in layout-split, then recent invoices full width
  • without upcoming: the other limits Card beside the recent invoices Card, in layout-split
  • the block is its own inline-size container; below --grid-breakpoint-md (64rem) of block width each row stacks

Props

NameTypeRequiredDefaultNotes
planobjectYes—{ name, price, priceNote?, nextCharge?, paymentMethod?, upgradeTo?, fit? }. Pre-formatted strings; Upgrade reads "Upgrade to {upgradeTo}". fit is one line on whether the upgrade plan covers this period, with a check icon.
allowanceobjectYes—UsageMeter props without its actions: { title, used, limit, unit?, categories?, periodStart?, resetLabel?, daily?, dailyLabels?, dailyCap?, warnAt?, paceNote?, overage? }.
upcomingobjectNo—The next invoice: InvoiceDocument props { number, to, from?, issuedOn, period?, lines, subtotal, taxLabel?, tax?, total, footnote? }, drawn with status "estimate" beside the other limits.
limitsarrayNo—UsageList items: { id, label, used, limit, unit?, note? }[]. The card line counts the ones at 80% or more.
invoicesarrayNo—{ id, number, date, amount, status: "paid" | "issued" | "overdue" | "void" }[], newest first. Status words match InvoiceDocument; "open" is kept as an alias of "issued".
invoiceLimitnumberNo4How many invoices to list.
onUpgradefunctionNo—() => void. On the plan card: the solid primary once the allowance is at or past its warnAt, outline below it. Without it there is no Upgrade.
onManagePaymentfunctionNo—() => void. Outline button on the plan card.
onDownloadInvoicefunctionNo—(invoiceId) => void. Each invoice row's Download action.
onViewInvoicesfunctionNo—() => void. View all link on the invoices card.
onViewUsagefunctionNo—() => void. The UsageMeter's View usage.
titlestringNoUsage & billing—
descriptionstringNo—Line under the heading.

Built from

  • Component
    →

    InvoiceDocument

    A document view for an invoice or a credit note, not a PDF engine: header with status and actions, bill-to and dates, line items, totals and one line about payment.

  • Component
    →

    UsageMeter

    Plan usage or AI credits against a limit: total, usage by category, daily bars toned against the cap, and a warning near the limit.

  • Component
    →

    PricingPlans

    An in-product plan comparison for upgrades, not a marketing page: a Monthly / Yearly switch, one card per plan with price, features and one CTA.

  • Component
    →

    Alert

    Inline status banner that stays on the page.