Billing Multi Currency Invoice Preview
An invoice line-item preview with a currency pill-toggle in the header. Every line item, the subtotal, tax, and total are stored once in USD and converted live when a different currency is selected, formatted with Intl.NumberFormat so symbols and decimal rules match the chosen locale. Built for billing portals that serve customers who bill in a currency other than the platform's base currency.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-multi-currency-invoice-preview.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing75.tsx instead.
Usage
The file also exports billing75Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Billing75, billing75Demo } from "@/components/blocks/billing/billing75"; export default function Page() { return <Billing75 {...billing75Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "Invoice preview" | Heading shown in the card header. |
| invoiceNumber | string | none | Optional invoice number or reference shown under the title. |
| lineItems | InvoiceLineItemUsd[] | none | Line items with amounts stored in USD; each is converted to the active currency for display. |
| taxRatePercent | number | 0 | Tax rate applied to the USD subtotal; the tax row only renders when this is greater than 0. |
| currencies | InvoiceCurrency[] | none | Currencies rendered as toggle pills, each with a rate applied to convert from USD. |
| defaultCurrencyCode | string | currencies[0].code | Which currency is active on first render. |
| downloadHref | string | "#" | Href for the Download PDF link. |
| className | string | none | Extra classes for the outer container. |
Types
interface InvoiceCurrency { code: string; symbol: string; rate: number; } interface InvoiceLineItemUsd { description: string; quantity?: number; amountUsd: number; }
Behavior notes
- The active currency is local component state; every amount on screen (line items, subtotal, tax, total) is recalculated from the USD source values whenever the toggle changes, with no page reload.
- Amounts are formatted with Intl.NumberFormat's currency style using the active currency's ISO code, so symbol placement and decimal precision follow that locale's convention automatically, not a hardcoded prefix.
- The tax row only renders when taxRatePercent is greater than 0, so invoices with no tax collapse to a two-line subtotal/total breakdown.
- The Download PDF link is a next/link with the current downloadHref, it doesn't itself regenerate a PDF in the selected currency, that's left to your backend.
- If a currency code you pass isn't a valid ISO 4217 code, Intl.NumberFormat throws; the component catches that and falls back to a plain two-decimal number for that currency.
Frequently asked questions
More Billing Blocks
View all →Billing Invoice List
Invoice history table with status badges, formatted amounts, and a per-row download link, built with shadcn/ui and Tailwind CSS.
Billing Failed Payment Alert
High-contrast failed-payment alert with a message, a retry button, and an optional update-payment-method button, built with shadcn/ui and Tailwind CSS.
Billing Credit Balance
Compact credit balance card with a large total, an optional purchased-versus-promotional breakdown, a low-balance notice, and a top-up button.
Billing Payment Methods
A saved payment method list for React and Next.js with brand icons, a default badge, near-expiry warnings, and remove/set-default actions per row.
Billing Add Card
A card entry form for React and Next.js with auto-formatted fields, internal brand detection, and per-field validation feedback built with shadcn/ui and Tailwind CSS.
Billing Coupon Code
An inline promo code input for React and Next.js with a simulated loading state, an applied summary showing the discount amount, and an invalid-code message.