Credit Card UI

A tailwind credit card ui: gradient bank card with chip, number, and holder details.

4242 4242 4242 4242

Card holder

Alex Morgan

Expires

12/28

Tailwind CSS
<div class="w-full max-w-sm aspect-[8/5] rounded-2xl bg-gradient-to-br from-slate-900 via-indigo-950 to-slate-900 p-6 text-white shadow-2xl flex flex-col justify-between">
  <div class="flex items-start justify-between">
    <div class="w-12 h-9 rounded-md bg-gradient-to-br from-amber-200 via-amber-300 to-amber-500"></div>
    <div class="flex -space-x-3">
      <div class="w-8 h-8 rounded-full bg-red-500/80"></div>
      <div class="w-8 h-8 rounded-full bg-amber-400/80"></div>
    </div>
  </div>
  <p class="tracking-[0.2em] text-lg font-mono">4242 4242 4242 4242</p>
  <div class="flex items-end justify-between text-xs">
    <div>
      <p class="text-slate-400 uppercase">Card holder</p>
      <p class="font-semibold tracking-wide">Alex Morgan</p>
    </div>
    <div>
      <p class="text-slate-400 uppercase">Expires</p>
      <p class="font-semibold">12/28</p>
    </div>
  </div>
</div>

Free to use in personal and commercial projects. No attribution required.

Variants

Same component, different looks. Preview each one live and copy the code you like.

Sunset

Warm gradient for travel or lifestyle brands instead of the dark original.

5312 7531 5312 7531

Card holder

Sara Ahmed

Expires

08/27

Tailwind CSS

Frosted light

Clean white card for minimal fintech apps and light dashboards.

4242 4242 4242 4242

Card holder

Alex Morgan

Expires

12/28

Tailwind CSS

Midnight blue

Deep blue gradient that reads premium for banking products.

PLATINUM

6011 6011 6011 6011

Card holder

Daniel Reyes

Expires

03/29

Tailwind CSS

About this credit card ui

A tailwind credit card ui renders a realistic bank card in pure CSS: a dark gradient body, a gold chip, a spaced card number, and holder details. It is the standard visual for checkout pages, wallet screens, and fintech dashboards, where showing the card builds confidence at the payment step.

The card keeps the real 8:5 bank-card ratio with aspect-[8/5] and fills it with a deep indigo-to-slate gradient. The chip is a small rounded rectangle with a metallic amber gradient, the number uses tracking and a mono font for the embossed feel, and the bottom row splits holder name and expiry. Two overlapping translucent circles suggest a payment network mark without copying any real logo.

Only ever use test numbers like 4242 in demos and screenshots; never paste a real card number into markup. Dark gradients read premium, while a light variant with slate text suits playful brands. This credit card design html css pattern also works as the front face of a flip animation for card-entry forms.

Typing card numbers into blank boxes feels like data entry, abstract and slightly suspicious. A realistic card visual makes the payment step tangible: visitors see where their money is going and the form feels like a familiar object. The card shape is universal visual shorthand, understood across languages without a single word. That recognition is why checkout pages with card visuals convert better than bare forms.

The card locks the real bank-card ratio with aspect-[8/5], so it looks right at any width. Inside, flex-col with justify-between pushes the chip row to the top and the holder details to the bottom, mimicking a real card's zones. The chip is a small rounded rectangle with a metallic amber gradient and inset lines suggesting the contact pattern. The number uses a monospace font with wide tracking for the embossed feel.

Mask the number live as 4-4-4-4 groups while typing; ungrouped sixteen-digit strings are where typos hide. Detect the card brand from the first two digits and swap the logo automatically; asking users to select Visa or Mastercard manually is a solved problem. Validate with the Luhn check on blur and flag errors before submit, while the field still has focus. Never store the full number in component state longer than needed; keep card data in the payment provider's fields, not yours.

Never render the CVC next to the card number on the front face. Real cards keep the security code on the back for a reason, and showing all three together in a demo teaches visitors that this layout is normal. It also trains the wrong mental model for your own forms. Keep the CVC in its own field, and if you build the flip animation, put it on the back face where it belongs.

Where to use it

  • ✓ Checkout pages
  • ✓ Fintech dashboards
  • ✓ Digital wallet screens
  • ✓ Payment settings pages

Customization tips

Recolor the gradient for brand variants (emerald for eco banks, rose for premium tiers). Add a flip-on-hover to reveal a back face with a signature strip and CVC. Build a light version with bg-slate-200 and slate-900 text.

Design notes

When to use

A CSS credit card visual belongs on checkout pages, wallet screens, and payment method pickers, where a realistic card makes the abstract act of paying feel tangible. The gradient body, chip, and spaced number are visual shorthand every shopper recognizes instantly. It works as a preview of the saved method or as the decorative face of a payment form.

What to avoid

Do not place form inputs directly over the busy gradient, because text on a dark textured background hurts readability and error states get lost. Avoid generating fake card numbers that look real, since users may mistake them for actual credentials. And skip the realistic card for simple pay buttons where a clean form converts better.

Accessibility

Never render realistic-looking full card numbers, even as placeholders, and keep any text on the card at strong contrast against the gradient. If the card is interactive, every region needs a proper label rather than relying on the visual metaphor.

Frequently asked questions

How do I make a credit card UI in Tailwind?

Use a rounded-2xl div with aspect-[8/5], a dark gradient background, and flex-col justify-between. Add a gold chip div, a tracking-widest mono card number, and a bottom row for holder name and expiry.

What aspect ratio should a bank card ui tailwind component use?

Real bank cards use the ISO ratio of 1.586, so aspect-[8/5] is a close and convenient match in Tailwind. It keeps the card looking right at any width.

Can I add a flip animation to this payment card component?

Yes. Wrap it in a perspective container and rotate the inner card 180 degrees on hover with rotate-y utilities, revealing a back face with the magnetic strip and CVC field.

How do I format the card number with spaces in a credit card UI?

Group the digits in fours with a small JavaScript formatter on input, or pre-format the display string as "4242 4242 4242 4242". Use a monospace font with tracking-widest for the classic embossed look. Never use a real card number in demos, use the standard 4242 test pattern.

How do I add a chip and brand logo to a CSS credit card?

Build the chip as a small rounded rectangle with a metallic gradient and a few inset lines suggesting the contact pattern. Place the brand mark as an SVG in the top-right corner, sized around 40 pixels wide. Check contrast against the card gradient, since chips and logos disappear on busy backgrounds.

Can I make a glassmorphism credit card?

Yes. Use bg-white/10 with backdrop-blur-xl over a vibrant gradient background so the frosted effect has something to refract. White text usually reads better than dark text on glass cards. The effect falls flat on plain backgrounds, so the backdrop behind the card matters more than the card styles themselves.

Customize it with our tools