shadcn.io is not affiliated with official shadcn/ui
Updated Card Billing Success Block for React
A billing panel confirming a new card: the card drawn in greyscale with its real facts, and a switch per subscription that picks which of them it pays for, with the next charges on the card adding up as you flip them.
Installation
Overview
Confirm a new card and let people decide what it pays for, with this card updated panel for React with Base UI. It's a billing panel in the usual shape: a heading and one sentence, then one frame with a plus mark on each corner. The first cell draws the new card in greyscale, with its brand in words, its last four digits and its expiry, never a logo, and says when it was saved and which card it replaces. The second lists three subscriptions, each with its next charge, its date and a Switch named "Charge this card" in the text color, with a line that says where the charge goes: the new card, or the old one if you turn it off. A row sums the next charges on the new card as the switches move. The foot's polite status line reports each change, and the Shine Button takes the person back to billing, the only colored control. It's built from Switch, Badge, Shine Button and Guides, with a CSS entrance only. On a phone the card comes first and the subscriptions follow. For subscription, meal-kit and membership apps.
FAQ
What stays in the page, and how do I wire it for real?
The whole panel: it describes a card that was already saved for a fictional account, so no card was stored or charged, and flipping a switch only changes the page's state and says so in the status line ("Nothing changed in this demo"). The card shows only its brand, its last four digits and its expiry, which is all your payment provider returns, and the page never takes a number: collect the card with your provider's hosted fields, which is a separate step. To wire it, call your billing API from flip to move that subscription's payment method, and update the row from the response.
What does turning a switch off mean?
That subscription keeps charging the old card, so the line under it changes to "Stays on" the old card and the total of the next charges drops by its amount. The panel starts with every switch on, because a new card usually replaces the old one everywhere. Edit PLANS for your subscriptions (an amount in cents, an ISO day, a name, a note) and NEW_CARD and OLD_CARD for the two cards.
Where do the count and the total come from?
From the switches, never typed: "3 of 3 subscriptions" counts the ones that are on and "Next charges on this card" sums their amounts in whole cents, so both follow every flip. Amounts are written with Intl.NumberFormat in a fixed en-US locale, each in a left-to-right span, and dates are fixed ISO strings written in UTC in time elements.
How do the switches work with a keyboard and a screen reader?
Each is named by what it does ("Charge Visa ending 4242 for Weekly box"), toggles with Space and keeps its state when you tab away, and the polite status line speaks the result of each flip. The Switch takes checked and onCheckedChange. It's drawn in the text color so the foot's button stays the only colored control.
Related
- Pro
Payment Method Billing
Payment and invoicesPayment methods in app settings: the card on file with an expiry warning, a backup bank account, a button that sets the default, and a dialog that checks and updates the card.
- Pro
Add Card Dialog
Payments and plansA transit wallet's payment methods page with its add-card dialog shown open: a card drawn in greys that fills in as you type, a number that groups itself and names its network, checks on the number, expiry and code, and an Add card button that keeps only the last four digits.
- Pro
Current Plan Billing
Plan and usageThe account's current plan in app settings: plan, price, renewal date and card, a change-plan action, every quota's usage this period on shared hairlines, and the next invoice.
- Pro
Payment Receipt Success
Payments and refundsA full-height payment confirmation split in two: what happened and what comes next on one side, an itemised receipt table with the tax worked out in cents, a copyable receipt number and a text download on the other.
- Pro
Account Restored Invoice Success
Payments and refundsA full-height confirmation for a paid overdue invoice: a framed before and now pair of the same four capabilities, locked while the account was suspended and unlocked in turn now, then what was settled, with what and when the next invoice goes out.
- Pro
Tax Details Billing
Payment and invoicesBilling address and tax ID in app settings: a form that checks the postal code and tax number against the country, an optional invoice note, and a live preview of the invoice header.