Skip to content

React Checkout Form

A glass React checkout form for card or UPI payments, with a live card preview, input formatting and an order summary.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/payment-checkout.json

Payment details

Choose how you'd like to pay.

Order summary

Amount due

$31.32

Pro planBilled monthly
$29.00
Sales tax (8%)
$2.32
Total due today
$31.32

  • Payments are encrypted end to end.
  • Cancel or change your plan anytime.

Checkout

Fill in any 16-digit card number, a name, an expiry like 12/29 and a CVC, or a UPI ID like name@bank.

Payment details

Choose how you'd like to pay.

Order summary

Amount due

$31.32

Pro planBilled monthly
$29.00
Sales tax (8%)
$2.32
Total due today
$31.32

  • Payments are encrypted end to end.
  • Cancel or change your plan anytime.

Files to copy

12 folders · 15 files · 4 packages
From theme/src/
  • blocks/{payment-checkout.tsx, icons.tsx}
  • components/button/
  • components/glass-card/
  • components/input/
  • components/spinner/
  • components/status-icons/
  • components/tabs/
  • blocks/payment-checkout/
  • hooks/{use-direction.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}
  • motion/{gate.ts, light-follower.ts, tokens.ts}
  • lib/{cn.ts, field-size.ts, form.ts, heading.ts, state-light.tsx}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/payment-checkout.jsonRegistry item: payment-checkout. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Card only, in euros, with a promo code

One method hides the tabs; currency and locale format the amounts. Try the code SHEEN10: onApplyPromo resolves to a discount line, or to null to reject a code.

Card payment details

Choose how you'd like to pay.

Team order summary

Amount due

285,60 €

Team plan5 seats, billed yearly
240,00 €
VAT (19%)
45,60 €
Total due today
285,60 €

  • Invoice by email

Without the flip and the light

flipCard and stateLight are on by default. Turn them off for the plain card: the preview stays on its front and the card is never lit. The same states are still written as text.

Plain card details

Choose how you'd like to pay.

Plain order summary

Amount due

$31.32

Pro planBilled monthly
$29.00
Sales tax (8%)
$2.32
Total due today
$31.32

  • Payments are encrypted end to end.
  • Cancel or change your plan anytime.

Card data and PCI DSS

The card fields are ordinary inputs, so onPay receives the raw card number, expiry and CVC. Do not post those to your own server: that puts it in PCI DSS scope (SAQ D). In production use your payment provider's hosted or tokenised fields (Stripe Elements, Adyen Drop-in, Braintree Hosted Fields) in place of the card inputs and pass only the token on, or treat this block as the layout and validation reference. The UPI method carries no card data.

Props

PropTypeDefaultDescription
linesCheckoutLine[]defaultLinesThe order summary rows (CheckoutLine[], default: a small demo order). Amounts are in major units. The default is sample content for demos and prototypes: pass your own in production.
currencystring"USD"Sets the ISO 4217 currency code (string, default "USD").
localestring"en-US"BCP 47 locale used to format amounts (string, default "en-US").
methodsPaymentMethod[]["card", "upi"]Which payment methods to offer, in tab order (PaymentMethod[], default ["card", "upi"]). With one method the tabs are hidden.
onPay((method: PaymentMethod, details: PaymentDetails) => void | Promise<void>)NoneCalled with valid details when the user pays. Return a promise to show a loading state; throw to show an error.
onApplyPromo((code: string) => CheckoutLine | null | undefined | Promise<CheckoutLine | null | undefined>)NoneShows a promo-code field. Resolve to a discount line (negative amount) to apply it, or to null to reject the code.
assurances{ icon?: ReactNode; text: ReactNode; }[]defaultAssurancesShort reassurance notes under the summary (default: two generic notes). Pass [] to hide them. The default is sample content for demos and prototypes: pass your own in production.
flipCardbooleantrueTurns the card preview over to its back (the security code strip) while the CVC field has focus (boolean, default true). Reduced motion cross-fades the two sides instead of turning.
stateLightbooleantrueLights the card by state (boolean, default true): amber while the payment is processing, red after a refusal, green once paid. The state is always written as text too.
labelsPartial<PaymentCheckoutLabels>defaultPaymentCheckoutLabelsEvery other string, for translation: labels={{ title: "…" }}; omitted keys keep the English of defaultPaymentCheckoutLabels. All 38 keys of PaymentCheckoutLabels are listed in the key table under the props table.
headingLevelHeadingLevelOption2Level of the headings (1 to 6, default 2); set it to fit the page's outline. "none" renders them as paragraphs with no heading role (for an example).
classNamestringNoneAdds extra classes to the outer glass card (string).
PaymentCheckoutLabels keys and English defaults (38)
Pass any key in labels; the rest keep the defaults of defaultPaymentCheckoutLabels.
KeyEnglish default
titlePayment details
subtitleChoose how you'd like to pay.
methodLabelPayment method
cardCard
upiUPI
cardNumberCard number
cardNameName on card
cardNamePlaceholderJane Doe
expiryExpiry
cvcCVC
upiIdUPI ID
upiPlaceholdername@bank
upiHintWe'll send a payment request to your UPI app.
pay(amount) => `Pay ${amount}`
payFailedYour payment didn't go through. Check your details and try again.
errorCardNumberEnter the 16-digit card number.
errorCardNameEnter the name shown on the card.
errorExpiryUse the format MM/YY.
errorExpiredThis card has expired.
errorCvcEnter 3 or 4 digits.
errorUpiEnter a UPI ID like name@bank.
summaryOrder summary
amountDueAmount due
totalTotal due today
promoPromo code
promoPlaceholderEnter a code
promoApplyApply
promoInvalidThat code isn't valid.
promoEmptyEnter a promo code first.
promoApplied(code, total) => `${code} applied. New total ${total}.`
promoRemoveShortRemove
promoRemove(code) => `Remove promo code ${code}`
promoRemoved(total) => `Promo code removed. Total ${total}.`
successPayment successful
successBody(amount) => `${amount} paid. A receipt is on its way.`
againMake another payment
previewNameYour name
processingProcessing your payment

Keyboard

KeysAction
TabThe method tabs, the fields, the promo field and the pay button.
←/→Switch between payment method tabs.
Enteron a fieldSubmit the form.
Focus into CVCThe card preview turns over to its back.

Accessibility

  • The flip and the state light are visual only: processing is announced through a status region, a refusal is an alert and the paid result takes focus.
  • Reduced motion: the preview cross-fades instead of turning, the check is drawn at once.
  • Errors are visible text linked to their field (aria-describedby); a failed check focuses the first invalid field.
  • onPay failures use role="alert"; promo changes and the paid result are announced through a status region.
  • The numeric fields raise the numeric keyboard and carry autocomplete hints (cc-number, cc-exp, cc-csc).

All exports on this page

  • PaymentCheckout — A checkout card: card or UPI details with live validation, an order summary, an optional promo code and a success state.
  • defaultPaymentCheckoutLabels — The English PaymentCheckoutLabels used when labels is omitted; a partial labels prop is merged over it.

When to use the payment checkout form

  • Use PaymentCheckout as a credit card form with a live card preview in the payment step of a purchase flow, where one side collects card or UPI details and the other shows an order summary with a total.
  • Use it for a subscription upgrade screen, passing lines like a Pro plan billed monthly and an onApplyPromo callback that returns a negative discount line for a valid code.
  • Use it for storefronts that serve India, since methods can be ["card", "upi"] or just ["upi"], and currency and locale control how every amount is formatted.
  • Skip it when you need to collect raw card data on your own servers; use your payment provider's hosted or tokenized fields and treat this block as a layout and validation reference.
  • Pair it with an Input for any billing address fields you add around it, and a Button-based confirmation page after the success panel. It already uses Tabs for method switching.

Frequently asked questions

20 blocks pages in all: browse them on All blocks.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .