Billing Update Card Modal
A payment method update dialog that opens from a trigger button and walks through entering a name, card number, expiry, and CVC, with the card number auto-formatted into groups of four and the brand (Visa, Mastercard, American Express) detected from the digits as the user types. Submitting shows a brief saving state before confirming success. Built as a layout to drop Stripe Elements or another PCI-compliant field provider into in place of the plain inputs.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its dialog, input, label, button dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-update-card-modal.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing144.tsx instead.
Usage
The file also exports billing144Demo, 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 { Billing144, billing144Demo } from "@/components/blocks/billing/billing144"; export default function Page() { return <Billing144 {...billing144Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| triggerLabel | string | "Update card" | Label on the button that opens the dialog. |
| heading | string | "Update payment method" | Dialog title. |
| description | string | "Your new card replaces the one currently on file." | Dialog description under the title. |
| currentBrand | string | none | Optional brand name of the card currently on file, shown as a note above the form. |
| currentLast4 | string | none | Optional last 4 digits of the card currently on file. |
| submitLabel | string | "Save card" | Label on the submit button before saving starts. |
| cancelLabel | string | "Cancel" | Label on the cancel button. |
| successTitle | string | "Card updated" | Title shown on the success screen. |
| successMessage | string | auto-generated from the detected brand and last 4 digits | Message shown on the success screen; falls back to a generated sentence if omitted. |
| className | string | none | Extra classes applied to the trigger button. |
Behavior notes
- Card brand is detected locally from the entered digits using simple prefix rules (4 for Visa, 51-55/22-27 for Mastercard, 34/37 for American Express) and shown as a label inside the card number field; it is never passed in as a prop or icon component.
- The card number and expiry inputs are reformatted on every keystroke, grouping the card number into 4-digit blocks and inserting the slash in MM/YY, both capped at their maximum digit length.
- Submit is disabled until the card number has at least 15 digits, the expiry has both parts filled in, the CVC has at least 3 digits, and a name is entered.
- Submitting moves through a form, processing, and success step with a 1 second simulated delay standing in for the real Stripe confirmCardSetup call. There's no real payment processing wired in.
- Closing the dialog resets all form fields and the step back to the start after the close animation finishes, so reopening it always begins from a blank form.
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.