v0.3.0 — MIT Licensed

Beautiful credit card
components for React

A lightweight, fully typed React component that renders realistic credit cards with 3D flip animations, automatic issuer detection, and premium visual themes.

4111 1111 1111 1111
JANE COOPER
VALID THRU12/28
123

Everything you need

Drop-in component with zero configuration required.

3D Flip Animation

Smooth CSS perspective-based flip when focusing the CVC field. 0.7s cubic-bezier transition for a premium feel.

Auto Issuer Detection

Automatically identifies Visa, Mastercard, Amex, Discover, JCB, Diners, Elo, and more from the card number prefix.

Rich Colors Mode

Toggle premium dark gradients with issuer-specific colors, metallic chip, and glowing text shadows.

Internationalization

Supports English, Portuguese (pt-BR), and Spanish locales. Labels like "VALID THRU" adapt automatically.

Zero CSS Required

All styles are inline. No external CSS imports needed. Works with any framework or styling solution out of the box.

Full TypeScript

Written in TypeScript with exported types for Focused, Issuer, CardSizes, and all props. Great DX guaranteed.

Try it yourself

Type in the fields below to see the card update in real time.

•••• •••• •••• ••••
YOUR NAME HERE
VALID THRU••/••
•••

Try typing a Visa number (starts with 4), Mastercard (51-55), or Amex (34/37) to see automatic issuer detection.

12 supported issuers

Automatically detected from the card number prefix.

Visa
Mastercard
Amex
Discover
Diners
JCB
Elo
Sodexo
VR
Ticket VR
Ticket VA
Alelo

Simple to use

Get started with just a few lines of code.

import { useState } from "react";
import { CreditCard, type Focused } from "react-credit-cards-library";

function PaymentForm() {
  const [card, setCard] = useState({
    number: "", name: "", expiry: "", cvc: "",
  });
  const [focus, setFocus] = useState<Focused>("");

  return (
    <>
      <CreditCard
        number={card.number}
        name={card.name}
        expiry={card.expiry}
        cvc={card.cvc}
        focus={focus}
        richColors
      />

      <input
        name="number"
        placeholder="Card Number"
        value={card.number}
        onChange={(e) => setCard({ ...card, number: e.target.value })}
        onFocus={() => setFocus("number")}
      />
      {/* ...more inputs for name, expiry, cvc */}
    </>
  );
}

API Reference

Fully typed props and exported utilities.

CreditCard Props

PropTypeRequiredDescription
numberstringYesCredit card number (raw or formatted)
namestringYesCardholder name displayed on front
expirystringYesExpiry date (e.g. "12/25")
cvcstringYesCVC/CVV code shown on back
focusFocusedYesWhich field is focused ("number" | "name" | "expiry" | "cvc" | "")
richColorsbooleanNoEnable premium dark gradient theme
locale"en" | "pt-BR" | "es"NoLocale for UI labels
cardSizesCardSizesNoCustom card dimensions (width, height, maxWidth, maxHeight)

Exports

ExportKindDescription
CreditCardComponentMain credit card component (React.memo)
formatCardNumberFunctionFormat a number string with bullet placeholders
getCardIssuerFunctionDetect issuer from card number prefix
ISSUERSConstantReadonly tuple of all supported issuer strings
FOCUSED_FIELDSConstantReadonly tuple of all valid focus values
FocusedType"number" | "name" | "expiry" | "cvc" | ""
IssuerTypeUnion of all supported issuer names