Billing overview
Self-contained billing settings page with an in-place morphing plan picker and prorated quote, scroll-revealed usage meters, inline payment card form with column-by-column digit turns, and payable invoice history.
import { BillingOverview } from '@uthereal/ui/billing-overview'Billing overview playground
Billing
Fieldnote Labs workspace
Current plan
Billed monthlyRenews Oct 14, 2026
15 seats · 1M API calls · 100 GBPayment method
Usage this period
Sep 14 – Oct 1312of15
912,480of1,000,000
38.4GBof100.0
Invoices
Sent to Emma Collins- Growth planSep 14 – Oct 13$199.00Sep 14, 2026Paid
- Log retention add-onCard declined by the bank$36.00Sep 3, 2026Failed
- Onboarding workshopBank transfer, due Sep 27$600.00Aug 28, 2026Due
- Growth planAug 14 – Sep 13$199.00Aug 14, 2026Paid
Overview
BillingOverview combines subscription management, metered usage, payment method editing, and invoice history inside one rule-divided surface. Selecting Upgrade or Change plan morphs the current-plan panel in place into a radio-group plan picker with a Monthly / Yearly switch, a gliding selection highlight, and a live prorated charge or credit quote.
Updating the payment card reveals an inline form for card number, expiry, and security code; saving turns the masked card digits column by column. Usage meters roll and fill when scrolled into view, switching to the warning role with a Near limit pill at 85% or above. Invoice rows display settlement status pills, one-click Download confirmation, and Pay now controls on due and failed rows.
Use BillingOverview for flat-tier or hybrid SaaS billing settings pages where plan changes happen in place. For daily spend charts, projected overages, and spend alerts, use Usage billing. For interactive budget forecasting with a confidence cone, use Usage forecast.
Usage
'use client'
import { BillingOverview } from '@uthereal/ui/billing-overview'
export function WorkspaceBilling({
billing,
}: {
billing: WorkspaceBillingData
}) {
return (
<BillingOverview
title="Billing"
description={billing.workspaceName}
plans={billing.plans}
defaultPlanId={billing.planId}
defaultInterval={billing.interval}
meters={billing.meters}
paymentMethod={billing.card}
invoices={billing.invoices}
recipientName={billing.recipientName}
currency={billing.currency}
onChangePlan={(planId, interval, quote) => {
void fetch('/api/billing/plan', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ planId, interval, quote }),
})
}}
onUpdatePayment={(paymentMethod) => {
void fetch('/api/billing/card', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(paymentMethod),
})
}}
onDownloadInvoice={(invoiceId) => {
window.open(`/api/billing/invoices/${invoiceId}.pdf`, '_blank')
}}
onPayInvoice={(invoiceId) => {
void fetch(`/api/billing/invoices/${invoiceId}/pay`, { method: 'POST' })
}}
/>
)
}Omit callbacks to run local state transitions with deterministic preview proration—no network requests or real charges occur inside the block. Never send raw card numbers directly through serializable schema props; only the last four digits and MM/YY expiry appear in paymentMethod.
Examples
Annual top-tier plan with overdue invoice
Configure defaultPlanId on the highest plan with defaultInterval="yearly", Euro currency (currency="EUR"), and German formatting (locale="de-DE"). The summary action switches from an accent upgrade CTA to an outline Change plan button, two meters cross 85% to display Near limit pills, and the overdue wire invoice exposes Pay now.
Billing
Nordlicht Engineering GmbH
Current plan
4.788 € billed yearlyRenews Nov 1, 2027
50 seats · 5M API calls · 500 GBPayment method
Usage this period
Oct 1 – Oct 3144of50
4.520.000of5.000.000
210,5GBof500,0
Invoices
Sent to Lukas Weber- Dedicated region add-onSEPA wire transfer, due Oct 31450,00 €Oct 2, 2026Due
- Scale plan (annual)Nov 1, 2025 – Oct 31, 20264.788,00 €Nov 1, 2025Paid
Fresh workspace without invoices
Pass an empty invoices array and description="" (or null from React) for a newly provisioned Starter workspace with no prior billing history and early usage well below plan limits.
Billing
Current plan
Billed monthlyRenews Nov 1, 2026
5 seats · 250k API calls · 25 GBPayment method
Usage this period
Oct 1 – Oct 312of5
18,400of250,000
1.8GBof25.0
Invoices
Sent to Maya ChenNo invoices yet.
Plan morph, meters, and invoices
Proration and confirmation rules
| Change type | Quote calculation | Confirmation action |
|---|---|---|
| Higher plan, same period | Prorates the price difference across the remaining days in the current term (Due today). | Upgrade to {name} |
| Lower plan, same period | Credits unused time on the current plan (Credit to next invoice). | Move to {name} |
| Period switch (monthly ↔ yearly) | Starts a new period today and credits unused time from the previous term. | Switch to {interval} |
| Unchanged selection | Displays $0.00 and disables confirmation. | Current (disabled) |
Invoice states
| Status | Pill tone & icon | Row actions |
|---|---|---|
paid | Success check | Download (transitions through loading spinner to check) |
due | Warning clock | Pay now + Download |
failed | Danger circle-alert | Pay now + Download |
Paying a due or failed row settles it in place to paid, updates the detail line with the active card's last four digits, announces the payment, and moves keyboard focus to the row's Download button.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
title | stringDefault: "Billing" | Heading and accessible section name. |
description | stringDefault: "Fieldnote Labs workspace" | Supporting line under the heading. Empty hides it; pass null from React to hide it without editing. |
plans | BillingPlan[]Default: [{"id":"starter","name":"Starter","monthly":49,"yearly":39,"summary":"5 seats · 250k API calls · 25 GB"},{"id":"growth","name":"Growth","monthly":199,"yearly":159,"summary":"15 seats · 1M API calls · 100 GB"},{"id":"scale","name":"Scale","monthly":499,"yearly":399,"summary":"50 seats · 5M API calls · 500 GB"}] | Plans in the picker, lowest first. Defaults to three sample plans (Starter, Growth, Scale). Edits do not reset a mounted instance. |
defaultPlanId | stringDefault: "growth" | Plan shown in the current-plan card on first render. Must be one of plans. |
defaultInterval | monthly | yearlyDefault: "monthly" | Billing period of the current plan on first render. Yearly prices are per month. |
meters | BillingMeter[]Default: [{"id":"seats","label":"Seats","used":12,"limit":15,"decimals":0},{"id":"calls","label":"API calls","used":912480,"limit":1000000,"decimals":0},{"id":"storage","label":"Storage","unit":"GB","used":38.4,"limit":100,"decimals":1}] | Usage meters for the current period; each fills to used over limit when scrolled into view. Defaults to seats, API calls, and storage. |
usagePeriodLabel | stringDefault: "Sep 14 – Oct 13" | Period line beside the usage heading. |
paymentMethod | PaymentMethodDefault: {"last4":"7719","expiry":"04/28","brand":"Business","holder":"Fieldnote Labs"} | Card on file. Only the last four digits and expiry ever render. |
recipientName | stringDefault: "Emma Collins" | Person invoices are sent to, beside the invoices heading. |
invoices | BillingInvoice[]Default: [{"id":"sep-renewal","date":"Sep 14, 2026","title":"Growth plan","detail":"Sep 14 – Oct 13","amount":199,"status":"paid"},{"id":"sep-retention","date":"Sep 3, 2026","title":"Log retention add-on","detail":"Card declined by the bank","amount":36,"status":"failed"},{"id":"aug-workshop","date":"Aug 28, 2026","title":"Onboarding workshop","detail":"Bank transfer, due Sep 27","amount":600,"status":"due"},{"id":"aug-renewal","date":"Aug 14, 2026","title":"Growth plan","detail":"Aug 14 – Sep 13","amount":199,"status":"paid"}] | Invoice history, newest first. Defaults to a four-row sample with one due and one failed row. |
currency | stringDefault: "USD" | ISO 4217 currency code for every amount, e.g. USD. |
changePlanAction | string— | Registered host action requested when the user confirms a plan change. |
updateCardAction | string— | Registered host action requested when the user saves a new card. |
downloadInvoiceAction | string— | Registered host action requested when an invoice is downloaded; passes the invoice id. |
payInvoiceAction | string— | Registered host action requested when a due or failed invoice is paid; passes the invoice id. |
changePlanLabel | stringDefault: "Change plan" | Button that opens the plan picker from the top plan. |
pickerTitleLabel | stringDefault: "Change plan" | Heading inside the plan picker. |
yearlyNoteLabel | stringDefault: "Yearly billing saves 20%" | Supporting line inside the plan picker. |
monthlyLabel | stringDefault: "Monthly" | Segment label for monthly billing. |
yearlyLabel | stringDefault: "Yearly" | Segment label for yearly billing. |
cancelLabel | stringDefault: "Cancel" | Button that closes the picker or card form without saving. |
currentPlanLabel | stringDefault: "Current" | Badge marking the current plan inside the picker. |
currentPlanCardLabel | stringDefault: "Current plan" | Heading of the current-plan card. |
renewsLabel | stringDefault: "Renews {date}" | Fact line in the current-plan card; the {date} placeholder fills with renewsOnLabel. |
renewsOnLabel | stringDefault: "Oct 14, 2026" | Renewal date of the term shown in the current-plan card. |
billedMonthlyLabel | stringDefault: "Billed monthly" | Panel note while the current plan is on monthly billing. |
billedYearlyLabel | stringDefault: "{amount} billed yearly" | Panel note while the current plan is on yearly billing; the {amount} placeholder fills with the yearly total. |
billingPeriodLabel | stringDefault: "Billing period" | Accessible name of the monthly or yearly segment control. |
perMonthShortLabel | stringDefault: "/mo" | Unit after a plan price in the picker. |
perMonthLabel | stringDefault: "/ month" | Unit after the current-plan price. |
billedYearlyOptionLabel | stringDefault: "{amount} a year" | Option billed line on yearly billing; the {amount} placeholder fills with the yearly total. |
dueTodayLabel | stringDefault: "Due today" | Quote label when the change charges the card. |
creditLabel | stringDefault: "Credit to next invoice" | Quote label when the change credits the account. |
proratedLabel | stringDefault: "Prorated for the days left in the term" | Quote detail for a same-period plan change. |
newPeriodLabel | stringDefault: "Starts a new period today; unused time is credited" | Quote detail for a billing-period switch. |
currentPlanNoteLabel | stringDefault: "This is your current plan" | Quote detail when the picker selection changes nothing. |
upgradeLabel | stringDefault: "Upgrade to {name}" | Confirm button for a higher plan; the {name} placeholder fills with the plan name. |
downgradeLabel | stringDefault: "Move to {name}" | Confirm button for a lower plan; the {name} placeholder fills with the plan name. |
switchIntervalLabel | stringDefault: "Switch to {interval}" | Confirm button for the same plan on the other period; the {interval} placeholder fills with monthly or yearly. |
switchedIntervalLabel | stringDefault: "Switched to {interval} billing" | Verb line of the confirmation for a billing-period switch; the {interval} placeholder fills with monthly or yearly. |
upgradedPlanLabel | stringDefault: "Upgraded to {name}" | Verb line of the confirmation for an upgrade; the {name} placeholder fills with the plan name. |
movedPlanLabel | stringDefault: "Moved to {name}" | Verb line of the confirmation for a downgrade; the {name} placeholder fills with the plan name. |
chargeConfirmationLabel | stringDefault: "{amount} charged to card ending {last4}." | Charge tail of the confirmation; {amount} and {last4} are filled. |
creditConfirmationLabel | stringDefault: "{amount} credited to your next invoice." | Credit tail of the confirmation; the {amount} placeholder fills with the formatted credit. |
cardSectionLabel | stringDefault: "Payment method" | Heading of the payment card section. |
updateCardLabel | stringDefault: "Update" | Button that opens the inline card form. |
saveCardLabel | stringDefault: "Save card" | Submit button of the inline card form. |
cardNumberLabel | stringDefault: "Card number" | Field label for the 16-digit card number. |
expiryLabel | stringDefault: "Expiry" | Field label for the MM/YY expiry. |
cvcLabel | stringDefault: "Security code" | Field label for the 3 or 4 digit security code. |
cardNumberError | stringDefault: "Enter all 16 digits" | Validation message for an incomplete card number. |
expiryError | stringDefault: "Use MM/YY, like 08/29" | Validation message for a malformed expiry. |
cvcError | stringDefault: "Enter 3 or 4 digits" | Validation message for an incomplete security code. |
savedCardLabel | stringDefault: "Card ending {last4} saved. Renewals and retries now use it." | Confirmation after a saved card; the {last4} placeholder fills with the new last four digits. |
cardEndingLabel | stringDefault: "Card ending {last4}" | Card title line; the {last4} placeholder fills with the last four digits. |
expiresLabel | stringDefault: "Expires {expiry}" | Card meta line; the {expiry} placeholder fills with the MM/YY expiry. |
usageSectionLabel | stringDefault: "Usage this period" | Heading of the usage meters section. |
ofLimitLabel | stringDefault: "of" | Joins the used value and the limit, e.g. 12 of 15. |
nearLimitLabel | stringDefault: "Near limit" | Warning pill on a meter at or past 85% of its limit. |
usedShareLabel | stringDefault: "{share}% used" | Meter caption share; the {share} placeholder fills with the whole percent of the limit in use. |
leftLabel | stringDefault: "{left} left" | Meter caption remainder; the {left} placeholder fills with the unused amount. |
invoicesSectionLabel | stringDefault: "Invoices" | Heading of the invoice history section. |
sentToLabel | stringDefault: "Sent to {name}" | Recipient line beside the invoices heading; the {name} placeholder fills with recipientName. |
paidLabel | stringDefault: "Paid" | Status pill for a settled invoice. |
dueLabel | stringDefault: "Due" | Status pill for an unpaid invoice. |
failedLabel | stringDefault: "Failed" | Status pill for a declined invoice. |
downloadLabel | stringDefault: "Download invoice from {date}" | Accessible name of a download button; the {date} placeholder fills with the invoice date. |
downloadedLabel | stringDefault: "Invoice from {date} downloaded" | Download button name once finished; the {date} placeholder fills with the invoice date. |
paidDetailLabel | stringDefault: "Paid with card ending {last4}" | Invoice detail line after settling; the {last4} placeholder fills with the card digits. |
payInvoiceLabel | stringDefault: "Pay now" | Visible text of the Pay now button. |
downloadedAnnouncement | stringDefault: "Invoice from {date} downloaded." | Polite announcement after a download; the {date} placeholder fills with the date. |
paidAnnouncement | stringDefault: "{amount} invoice from {date} paid with card ending {last4}." | Polite announcement after a payment; {amount}, {date}, and {last4} are filled. |
locale | string— | BCP 47 locale for currency and count formatting; inherited when omitted. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | BillingOverviewThemeDefault: {} | Color mode, accent, and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | BillingOverviewMotionOptionsDefault: {} | Morph, meter fill, digit turn, and copy swap timing overrides in milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
BillingPlanaccepts{ id, name, monthly, yearly, summary }, ordered lowest first (2to8plans, unique IDs).BillingMeteraccepts{ id, label, unit?, used, limit, decimals? }(1to6meters, unique IDs).PaymentMethodaccepts{ last4, expiry, brand?, holder? }, wherelast4is 4 digits andexpiryisMM/YY.BillingInvoiceaccepts{ id, date, title, detail, amount, status? }(0to60invoices, unique IDs; negativeamountrepresents a credit).
React integration
| Prop | Purpose |
|---|---|
description | Supporting line under the heading; pass "" or null to hide it. |
onChangePlan(planId, interval, quote) | Called when the user confirms a plan or billing-period change. |
onUpdatePayment(paymentMethod) | Called when the inline card form passes validation and saves. |
onDownloadInvoice(invoiceId) | Called when the user activates an invoice download button. |
onPayInvoice(invoiceId) | Called when the user activates Pay now on a due or failed invoice. |
onPickChange({ planId, interval }) | Called on every plan or monthly/yearly toggle change inside the picker. |
onAction(action, itemId?) | Called with changePlanAction, updateCardAction, downloadInvoiceAction (with invoice ID), or payInvoiceAction (with invoice ID). |
preset | Application defaults overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme, forwarded to the root and nested controls. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root element. |
Keyboard & accessibility
| Key | Action |
|---|---|
ArrowUp / ArrowDown / ArrowLeft / ArrowRight | Moves selection across plans in the picker radio group (horizontal arrows respect RTL). |
Home / End | Jumps to the first or last plan in the picker. |
Escape | Closes the plan picker or cancels inline card editing and returns focus to its trigger. |
Tab | Moves across plan controls, card form inputs, Pay now, and Download buttons. |
- The plan picker exposes
role="radiogroup"with rovingtabIndexrole="radio"options; the live quote sits inside anaria-live="polite"region. - Every
OdometerNumberpairsaria-hidden="true"digit wheels with visually hidden plain text, and each usage bar exposesrole="meter"witharia-valuemin,aria-valuemax,aria-valuenow, andaria-valuetext. - The inverted card face is marked
aria-hidden="true"while plain summary text beside it names the card ending and expiry; card digits and expiry staydir="ltr"inside RTL layouts. - Focus moves intentionally across state changes (into the picker, to the first invalid card input on submit error, back to the trigger on cancel/save, and onto Download after paying an invoice).
- A pre-mounted polite
role="status"live region announces plan changes, card saves, invoice downloads, and payments. - Container queries stack plan and payment panels below
780px, switch meters to one column and wrap invoice rows below700px, stretch quote actions below480px, and stack card expiry/CVC fields below340px.
Motion & theming
Panel swaps morph inside an AutoHeight spring container (morph spring), the active plan highlight glides via a shared layoutId, copy lines rise and exit via AnimatePresence, numeric totals turn on OdometerNumber wheels, card digits flip column by column, and meter bars fill with a staggered smooth spring once 30% in view.
Under prefers-reduced-motion: reduce, height springs, shared highlight glide, digit travel, and meter stagger drop to immediate jumps while copy swaps keep a 120ms opacity crossfade. Setting motion="none" makes every swap and meter fill immediate (0ms) and removes simulated settle delays.
theme accepts mode, accent, and typed tokens across these groups:
| Token group | CSS custom properties |
|---|---|
core | --ui-surface, --ui-surface-raised, --ui-text, --ui-text-secondary, --ui-muted, --ui-border, --ui-highlight, --ui-accent, --ui-accent-foreground, --ui-danger, --ui-focus-ring, --ui-radius, --ui-border-width, --ui-shadow, --ui-disabled-opacity, --ui-font, --ui-font-size, --ui-font-weight |
extended | --ui-surface-sunken, --ui-border-strong, --ui-border-subtle, --ui-track, --ui-info, --ui-success, --ui-warning, --ui-tone-foreground, --ui-overlay, --ui-tint-strength |
shape | --ui-radius-sm, --ui-popup-radius, --ui-surface-radius |
selectionControl | --ui-control-on, --ui-control-glyph, --ui-track, --ui-control-track-hover, --ui-control-thumb, --ui-control-thumb-on, --ui-control-fill, --ui-shadow-thumb |
elevation | --ui-shadow-resting, --ui-shadow-raised |
type | --ui-font-mono, --ui-font-display |
An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, BillingOverview is a leaf block. Order plans lowest first, keep plan, meter, and invoice IDs unique, never include full card numbers, and wire action refs only to registered host actions. See Building with agents.
{
"type": "BillingOverview",
"props": {
"title": "Billing",
"description": "Northwind workspace",
"defaultPlanId": "growth",
"defaultInterval": "monthly",
"currency": "USD",
"changePlanAction": "change_billing_plan",
"updateCardAction": "update_payment_card",
"downloadInvoiceAction": "download_invoice",
"payInvoiceAction": "pay_invoice"
},
"children": []
}