Billing Currency Switcher
A compact currency switcher for pricing pages, a row of currency codes as toggle pills and a large price that recalculates instantly when the user picks a different one. Prices are derived from a single base USD amount and a per-currency exchange rate you provide. Built for international SaaS pricing pages and global checkout flows where visitors expect to see a price in their own currency.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-currency-switcher.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing42.tsx instead.
Usage
The file also exports billing42Demo, 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 { Billing42, billing42Demo } from "@/components/blocks/billing/billing42"; export default function Page() { return <Billing42 {...billing42Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Choose your currency" | Heading shown above the toggle row. |
| description | string | none | Optional supporting line under the heading. |
| basePriceUsd | number | none | The reference price in US dollars that every currency's rate is applied to. |
| currencies | CurrencyOption[] | none | Currencies rendered as toggle pills, in the order given. |
| defaultCurrencyCode | string | currencies[0].code | Which currency is active on first render. |
| period | string | "/mo" | Suffix shown after the price, for example a billing interval. |
| className | string | none | Extra classes for the outer container. |
Types
interface CurrencyOption { code: string; symbol: string; label: string; rate: number; }
Behavior notes
- The active currency is local component state, switching pills recalculates the displayed price as basePriceUsd times the selected currency's rate, with no page reload or refetch.
- The price symbol is always shown as a prefix (for example "$49"); there's no suffix-symbol mode for currencies that conventionally place the symbol after the amount.
- Amounts round to whole numbers when the result is an integer and to two decimal places otherwise, there's no per-currency decimal-place rule (for example JPY normally shows no decimals).
- Selecting a currency doesn't persist anywhere by itself, save the chosen code to a cookie or localStorage yourself if you want it remembered across visits.
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.