1.1.3 • Published 2 years ago
creactid-card v1.1.3
creactid-card
creactid-card is an easy-to-use credit card component for your projects. Supports 12 credit cards and provides a different design for each one.
Supported Credit Cards
- Visa
- Mastercard
- American Express
- Diners Club
- Discover
- JCB
- UnionPay
- Maestro
- Elo
- Mir
- Hiper
- Hipercard
Demo Gif

Installation
npm install creactid-cardUsage
import { CreditCard } from 'creactid-card';
import { useState } from 'react';
export default function CreditCardExample() {
  const [cardInfo, setCardInfo] = useState({
    cardNumber: '',
    cardholderName: '',
    expYear: '',
    expMonth: '',
    cvv: '',
    focus: '',
    placeholder: '',
  });
  const handleFocus = (event) => {
    setCardInfo((prev) => ({
      ...prev,
      focus: event.target.name,
    }));
  };
  const handleChange = (event) => {
    const { name, value } = event.target;
    setCardInfo((prev) => ({
      ...prev,
      [name]: value,
    }));
  };
  return (
    <div>
      <form>
        <label>Card Number</label>
        <input
          name="cardNumber"
          onChange={handleChange}
          onFocus={handleFocus}
          placeholder="Ex: 55.. ...."
        />
      </form>
      // All form elements
      <CreditCard
        cardNumber={cardInfo.cardNumber}
        cardholderName={cardInfo.cardholderName}
        placeholder={cardInfo.placeholder}
        expYear={cardInfo.expYear}
        expMonth={cardInfo.expMonth}
        cvv={cardInfo.cvv}
        focus={cardInfo.focus}
      />
    </div>
  );
}Properties
| Name | Type | Default | Description | 
|---|---|---|---|
| cardNumber | {String} | Card number | |
| cardholderName | {String} | Cardholder name | |
| expMonth | {String} | Expiration month | |
| expYear | {String} | Expiration year | |
| cvv | {String} | CVV/CVC number | |
| placeholder | {String} | Your Name | Placeholder for the cardholder name. You can write it any language you want. | 
| focus | {String} | Should take the name of the input focusing on. In this way, back side of credit card is visible. | 
Note: For the back of credit card to be visible, focus prop must be "cvv".