React Credit Card Flipping
Credit card flipping for ReactJS
Install
npm install react-credit-card-flipping
ou
yarn add react-credit-card-flipping
Usage
import React, { useState } from 'react';
import Card from 'react-credit-card-flipping';
export default function App() {
const [cardNumber, setCardNumber] = useState('');
const [cardName, setCardName] = useState('');
const [cardBrand, setCardBrand] = useState('');
const [cardExpiry, setCardExpiry] = useState('');
const [cardCVV, setCardCVV] = useState('');
const [focusCVV, setFocusCVV] = useState(false);
return (
<div id="form">
<Card
number={cardNumber}
name={cardName}
expiry={cardExpiry}
cvv={cardCVV}
flipCard={focusCVV}
/>
<form>
<input
type="tel"
name="number"
placeholder="Card Number"
onChange={(event) => setCardNumber(event.target.value)}
/>
...
<input
type="tel"
name="cvv"
placeholder="CVV"
onChange={(event) => setCardCVV(event.target.value)}
onFocus={() => setFocusCVV(true)}
onBlur={() => setFocusCVV(false)}
/>
</form>
</div>
);
}
Props
name
{string}: Cardholder Name - requirednumber
{string|number}: Card number - requiredexpiry
{string}: Card expiry date 01/20
- requiredcvv
{string|number}: Card CVC/CVV - requiredbrand
{string}: Card brand URL
- optionalbackgroundColor
{string}: Card background color when empty. Default: #DDD
- optionalfilledBackgroundColor
{string}: Card background color when not empty. Default: #134869
- optionalflipCard
{boolean} Flip card when there`s focus or blur on CVV input - optionalemptyName
{string} Default value when name is empty. Default: Cardholder Name
- optional
LICENSE
This project is licensed under the MIT License.
Development by: André Coelho