card-react
React credit card component
jessepollak's Card make credit card forms look awesome.
card-react is a React component that aims to do the same for React.
![card](http://i.imgur.com/qG3TenO.gif)
From version 1.1.20 card-react supports React 0.14.7 and up
Features
- Validate inputs
- Format form inputs
- Identify card type
- Initialize the card element with user details
- The card element itself don't have to be a child of the form - it can be rendered anywhere
How to install
npm install card-react
- Add
card.css
file to your project's stylesheets. You can find it at lib/
folder.
Usage
Include card-react in your code:
import CardReactFormContainer from 'card-react';
Once included, you can initialize the component. you'll need to make the component the container of your form:
<CardReactFormContainer
container="card-wrapper"
formInputsNames={
{
number: 'CCnumber',
expiry: 'CCexpiry',
cvc: 'CCcvc',
name: 'CCname'
}
}
initialValues= {
{
number: '4242424242424242',
cvc: '123',
expiry: '16/12',
name: 'Random Name'
}
}
classes={
{
valid: 'valid-input',
invalid: 'invalid-input'
}
}
formatting={true}
>
<form>
<input placeholder="Full name" type="text" name="CCname" />
<input placeholder="Card number" type="text" name="CCnumber" />
<input placeholder="MM/YY" type="text" name="CCexpiry" />
<input placeholder="CVC" type="text" name="CCcvc" />
</form>
</CardReactFormContainer>
<div id="card-wrapper"></div>
To run the example:
Development
Future Plans
You are more than welcome to contribute. Enjoy!