Billing overview
Workspace billing card with inline plan switcher, seat usage bar, saved card summary and downloadable recent invoices.
pnpm dlx shadcn@latest add @haze/billing-overview---
import { ArrowUpRight, Check, CreditCard, Download, Sparkles } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
interface Invoice {
id: string;
date: string;
amount: string;
status: "Paid" | "Open";
}
interface Props {
id?: string;
invoices?: Invoice[];
class?: string;
}
const {
id = "haze-billing-overview",
invoices = [
{ id: "INV-2026-11", date: "Nov 1, 2026", amount: "$89.00", status: "Paid" },
{ id: "INV-2026-10", date: "Oct 1, 2026", amount: "$89.00", status: "Paid" },
{ id: "INV-2026-09", date: "Sep 1, 2026", amount: "$89.00", status: "Paid" },
],
class: className,
} = Astro.props;
const plans = [
{ name: "Starter", price: "$29/mo", note: "5 seats · 50k requests" },
{ name: "Team", price: "$89/mo", note: "20 seats · 250k requests" },
{ name: "Scale", price: "$249/mo", note: "Unlimited seats · SAML SSO" },
];
---
<section aria-labelledby={`${id}-title`} data-haze-billing-overview class={cn("bg-background px-4 py-10 sm:px-6 sm:py-14", className)}>
<div class="mx-auto max-w-4xl space-y-4">
<div class="rounded-2xl border border-border bg-card p-5 sm:p-6">
<div class="flex flex-wrap items-start justify-between gap-3">
<div>
<span class="inline-flex items-center gap-1.5 rounded-full border border-frame bg-muted px-2.5 py-0.5 text-xs font-medium text-foreground">
<Sparkles class="size-3.5" aria-hidden="true" />
Current plan
</span>
<h2 id={`${id}-title`} data-bo-plan-name class="mt-2 text-xl/7 font-semibold tracking-tight text-foreground">Team · $89 / month</h2>
<p class="mt-0.5 text-xs/5 text-muted-foreground">Renews Dec 1, 2026 · 14 of 20 seats used</p>
</div>
<button type="button" data-bo-toggle-plans aria-expanded="false" class="inline-flex h-9 cursor-pointer items-center gap-1.5 rounded-lg border border-frame bg-field px-3.5 text-xs font-medium text-foreground hover:border-frame-strong hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
Change plan
<ArrowUpRight class="size-3.5" aria-hidden="true" />
</button>
</div>
<div data-bo-picker hidden class="mt-4 grid gap-2.5 border-t border-border pt-4 sm:grid-cols-3">
{
plans.map((p) => (
<button
type="button"
data-bo-pick={`${p.name} · ${p.price}`}
class="flex cursor-pointer flex-col items-start rounded-xl border border-border bg-muted/40 p-3.5 text-left transition-colors duration-150 hover:border-border-strong hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring active:scale-[0.97] active:duration-75"
>
<span class="text-sm font-semibold text-foreground">{p.name}</span>
<span class="mt-0.5 font-mono text-xs text-muted-foreground">{p.price}</span>
<span class="mt-1 text-[0.6875rem] text-muted-foreground">{p.note}</span>
</button>
))
}
</div>
<div class="mt-5 grid gap-3 border-t border-border pt-5 sm:grid-cols-2">
<div class="rounded-xl border border-border bg-muted/40 p-3.5">
<div class="flex justify-between text-xs">
<span class="font-medium text-foreground">Seats</span>
<span class="font-mono text-muted-foreground tabular-nums">14 / 20</span>
</div>
<div class="mt-2 h-1.5 overflow-hidden rounded-full bg-muted"><div class="h-full rounded-full bg-primary" style="width: 70%"></div></div>
</div>
<div class="flex items-center justify-between gap-3 rounded-xl border border-border bg-muted/40 p-3.5">
<div class="flex items-center gap-2.5">
<CreditCard class="size-4 text-muted-foreground" aria-hidden="true" />
<div class="text-xs">
<p class="font-medium text-foreground">Visa ending in 4242</p>
<p class="text-muted-foreground">Expires 09/2028</p>
</div>
</div>
<button type="button" data-bo-card class="inline-flex h-7 cursor-pointer items-center rounded-md border border-frame bg-field px-2.5 text-xs font-medium text-foreground hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">Update</button>
</div>
</div>
<div class="mt-5 border-t border-border pt-5">
<h3 class="text-xs/4 font-medium tracking-wider text-muted-foreground uppercase">Recent invoices</h3>
<ul role="list" class="mt-2.5 divide-y divide-border rounded-xl border border-border bg-muted/40 text-xs">
{
invoices.map((inv) => (
<li class="flex flex-wrap items-center justify-between gap-2 px-3.5 py-2.5">
<span class="font-mono font-medium text-foreground">{inv.id}</span>
<span class="text-muted-foreground">{inv.date}</span>
<span class="font-mono font-medium text-foreground tabular-nums">{inv.amount}</span>
<span class="inline-flex items-center gap-1 rounded-md border border-frame-success bg-success/10 px-2 py-0.5 text-[0.6875rem] font-medium text-success">
<Check class="size-3" aria-hidden="true" />
{inv.status}
</span>
<button type="button" data-bo-dl={inv.id} aria-label={`PDF for invoice ${inv.id}`} class="inline-flex h-7 cursor-pointer items-center gap-1 rounded-md px-2 text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
<Download class="size-3.5" aria-hidden="true" />
PDF
</button>
</li>
))
}
</ul>
</div>
<p data-bo-status role="status" class="mt-3 min-h-4 text-xs/4 text-muted-foreground"></p>
</div>
</div>
</section>
<script>
function initBillingOverviews() {
document.querySelectorAll<HTMLElement>("[data-haze-billing-overview]").forEach((root) => {
if (root.hasAttribute("data-enhanced")) return;
root.setAttribute("data-enhanced", "");
const toggle = root.querySelector<HTMLButtonElement>("[data-bo-toggle-plans]");
const picker = root.querySelector<HTMLElement>("[data-bo-picker]");
const name = root.querySelector<HTMLElement>("[data-bo-plan-name]");
const status = root.querySelector<HTMLElement>("[data-bo-status]");
toggle?.addEventListener("click", () => {
if (!picker) return;
picker.hidden = !picker.hidden;
toggle.setAttribute("aria-expanded", String(!picker.hidden));
});
root.querySelectorAll<HTMLButtonElement>("[data-bo-pick]").forEach((btn) => {
btn.addEventListener("click", () => {
if (name) name.textContent = btn.dataset.boPick ?? "";
if (picker) picker.hidden = true;
toggle?.setAttribute("aria-expanded", "false");
if (status) status.textContent = `Switched plan to ${btn.dataset.boPick}.`;
});
});
root.querySelector<HTMLButtonElement>("[data-bo-card]")?.addEventListener("click", () => {
if (status) status.textContent = "Opened payment method editor.";
});
root.querySelectorAll<HTMLButtonElement>("[data-bo-dl]").forEach((btn) => {
btn.addEventListener("click", () => {
if (status) status.textContent = `Prepared PDF receipt for ${btn.dataset.boDl}.`;
});
});
});
}
initBillingOverviews();
document.addEventListener("astro:page-load", initBillingOverviews);
</script>When to use
- Showing current subscription plan, seat utilization, payment card and invoice history in one view
- Letting admins swap plans inline without navigating away from billing
When not to use
- Tracking metered usage spend against a soft/hard budget cap; use usage-billing
Installation
Add the Haze registry to components.json once, then install Billing overview with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/billing-overviewnpx shadcn@latest add @haze/billing-overviewyarn dlx shadcn@latest add @haze/billing-overviewbunx --bun shadcn@latest add @haze/billing-overviewFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | "haze-billing-overview" | Unique prefix for section heading IDs. |
| invoices | { id: string; date: string; amount: string; status: string }[] | 3 paid invoices | Recent invoice rows with PDF download actions. |
| class | string | – | Extra classes on the outer section. |
Keyboard interactions
- Tab
- Move across Change plan, plan cards, payment Update and invoice PDF buttons
- EnterSpace
- Open/close the plan picker, select a new plan or download an invoice
Accessibility
- The Change plan button exposes aria-expanded to toggle the inline plan picker.
- Plan switches, card updates and invoice downloads announce results via role="status".
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI block "Billing overview" with `npx shadcn@latest add @haze/billing-overview`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import BillingOverview from "@/components/haze/blocks/billing-overview.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/billing-overview.md
Customize with real content
Adapt the Haze billing-overview block for our product. Replace the demo values of these props with our real content: id, invoices, class. Keep the layout, the heading level rules and these accessibility details: The Change plan button exposes aria-expanded to toggle the inline plan picker. Plan switches, card updates and invoice downloads announce results via role="status". Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using billing-overview, check it fits: use it when showing current subscription plan, seat utilization, payment card and invoice history in one view; letting admins swap plans inline without navigating away from billing. Avoid it when tracking metered usage spend against a soft/hard budget cap; use usage-billing. Alternatives: @haze/pricing-three-tier, @haze/usage-meter.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.