Staaarter

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.

By Staaarter Team
Billing
Updated July 8, 2026
Docs
Live preview

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.json

Prefer 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

PropTypeDefaultDescription
triggerLabelstring"Update card"Label on the button that opens the dialog.
headingstring"Update payment method"Dialog title.
descriptionstring"Your new card replaces the one currently on file."Dialog description under the title.
currentBrandstringnoneOptional brand name of the card currently on file, shown as a note above the form.
currentLast4stringnoneOptional last 4 digits of the card currently on file.
submitLabelstring"Save card"Label on the submit button before saving starts.
cancelLabelstring"Cancel"Label on the cancel button.
successTitlestring"Card updated"Title shown on the success screen.
successMessagestringauto-generated from the detected brand and last 4 digitsMessage shown on the success screen; falls back to a generated sentence if omitted.
classNamestringnoneExtra 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