Billing and invoices
The plan, the card and the invoices, with usage against the plan’s limits.
131 lines · React · Tailwind 4
Install
$ bunx shadcn@latest add @blocco/billing-invoicesCode
import { Button } from "@/registry/blocco/ui/button";
import { Download } from "@/registry/blocco/ui/icons";
import { Badge, Table, Td, Th } from "@/registry/blocco/ui/misc";
import { SettingsGroup, SettingsRow } from "@/registry/blocco/ui/settings-rows";
import { cn } from "@/registry/blocco/ui/cn";
import { useToast } from "@/registry/blocco/ui/toast";
const usage = [
{ label: "Links", used: 184, limit: 500, unit: "links" },
{ label: "Members", used: 8, limit: 10, unit: "members" },
{ label: "Custom domains", used: 2, limit: 3, unit: "domains" },
{ label: "Clicks this month", used: 41_280, limit: 50_000, unit: "clicks" },
];
const invoices = [
{ id: "INV-1042", date: "Nov 1, 2026", amount: "$24.00", status: "Paid" },
{ id: "INV-1031", date: "Oct 1, 2026", amount: "$24.00", status: "Paid" },
{ id: "INV-1019", date: "Sep 1, 2026", amount: "$24.00", status: "Paid" },
{ id: "INV-1004", date: "Aug 1, 2026", amount: "$24.00", status: "Paid" },
];
const fmt = (n: number) => n.toLocaleString("en");
/** The plan, the card on file, usage against the plan's limits and past invoices. */
export default function BillingInvoices() {
const toast = useToast();
return (
<section className="mx-auto max-w-[760px] px-4 py-10 sm:px-6 sm:py-12">
<div className="mb-6">
<h1 className="text-xl font-semibold tracking-tight text-balance">Billing</h1>
<p className="mt-1 text-sm text-muted">Your plan, your card and what you have used.</p>
</div>
<div className="grid grid-cols-[minmax(0,1fr)] gap-8">
<SettingsGroup title="Plan and payment">
<SettingsRow label="Pro plan" hint="$24 a month. Renews Dec 1, 2026.">
<Button variant="outline" size="sm" onClick={() => toast("Plan change opened")}>
Change plan
</Button>
</SettingsRow>
<SettingsRow label="Card" hint="Visa ending 4242, expires 08/28.">
<Button variant="outline" size="sm" onClick={() => toast("Card form opened")}>
Update card
</Button>
</SettingsRow>
<SettingsRow label="Billing email" hint="Receipts go here.">
<span className="font-mono text-sm [overflow-wrap:anywhere]">billing@acme.test</span>
</SettingsRow>
</SettingsGroup>
<SettingsGroup title="Usage" hint="Resets on Dec 1.">
{usage.map((u) => {
const pct = Math.min(100, (u.used / u.limit) * 100);
const near = pct >= 80;
return (
<div key={u.label} className="px-4 py-3.5">
<div className="flex flex-wrap items-baseline justify-between gap-x-3">
<span className="text-sm font-medium">{u.label}</span>
<span className="tnum text-sm text-muted">
{fmt(u.used)} of {fmt(u.limit)} {u.unit}
</span>
</div>
<div
role="progressbar"
aria-label={u.label}
aria-valuemin={0}
aria-valuemax={u.limit}
aria-valuenow={u.used}
className="mt-2 h-2 overflow-hidden rounded-full bg-surface-2"
>
<div
className={cn("h-full rounded-full", near ? "bg-butter" : "bg-accent")}
style={{ width: `${pct}%` }}
/>
</div>
{near && (
<p className="tnum mt-1.5 text-xs text-muted">
{Math.round(pct)}% used. Upgrade to raise this limit.
</p>
)}
</div>
);
})}
</SettingsGroup>
<section className="flex flex-col gap-2">
<h2 className="text-sm font-medium text-muted">Invoices</h2>
<Table minWidth="min-w-[30rem]">
<thead>
<tr>
<Th>Invoice</Th>
<Th>Date</Th>
<Th className="text-right">Amount</Th>
<Th>Status</Th>
<Th className="w-12">
<span className="sr-only">Download</span>
</Th>
</tr>
</thead>
<tbody>
{invoices.map((inv) => (
<tr key={inv.id}>
<Td>
<span className="font-mono text-xs">{inv.id}</span>
</Td>
<Td className="tnum text-muted">{inv.date}</Td>
<Td className="tnum text-right">{inv.amount}</Td>
<Td>
<Badge color="mint">{inv.status}</Badge>
</Td>
<Td className="p-0 text-right">
<button
type="button"
aria-label={`Download ${inv.id}`}
onClick={() => toast("Invoice downloaded", "info", { code: inv.id })}
className="inline-flex size-10 cursor-pointer items-center justify-center rounded-md text-muted transition-colors duration-150 hover:text-text focus-visible:outline-2 focus-visible:outline-accent"
>
<Download size={16} />
</button>
</Td>
</tr>
))}
</tbody>
</Table>
</section>
</div>
</section>
);
}