sbycrosz/react-native-credit-card-input

Easy, cross-platform credit-card input for your React Native Project! Start accepting payment πŸ’° in your app today!

TypeScript

1,508

14 commits

updated Nov 10, 2025

See the code

README

React Native Credit Card Input - Finally updated in 2024!

Example on Expo Snack - Easy (and good looking) credit-card input for your React Native Project πŸ’³ πŸ’³

Code:

<CreditCardInput />
// or
<LiteCreditCardInput />

Features

  • Skeuomorphic credit-card πŸ’³
  • Lite version for smaller screens / compact layout
  • Credit-card input validations & formatting while you're typing
  • Form is fully navigatable using keypad
  • Works on both Android, iOS and Web!

Usage

yarn add react-native-credit-card-input

then add these lines in your react-native codebase

import { CreditCardInput, LiteCreditCardInput } from "react-native-credit-card-input";

<CreditCardInput onChange={_onChange} />
// or
<LiteCreditCardInput onChange={_onChange} />

// Note: You'll need to enable LayoutAnimation on android to see LiteCreditCardInput's animations
// UIManager.setLayoutAnimationEnabledExperimental(true);

And then on your onChange handler:

_onChange => form => console.log(form);

// will print:
{
  valid: true, // will be true once all fields are "valid" (time to enable the submit button)
  values: { // will be in the sanitized and formatted form
  	number: "4242 4242",
  	expiry: "06/19",
  	cvc: "300",
  	type: "visa", // will be one of [null, "visa", "master-card", "american-express", "diners-club", "discover", "jcb", "unionpay", "maestro"]
  },
  status: {  // will be one of ["incomplete", "invalid", and "valid"]
	number: "incomplete",
	expiry: "incomplete",
	cvc: "incomplete",
  },
};

Example

Expo Snack

Or run it locally

yarn install

yarn example ios
# or
yarn example android
# or
yarn example web

Should I used this in my project?

  • Yes, if you need a quick credit card input component for your project or proof of concept.
  • Yes, if the current UI/component fit your use case
  • Otherwise, you're probably better off using your favorite form library and implementing the validation with the card-validator package!

Components

LiteCreditCardInput

PropTypeDescription
autoFocusbooleanOptional. Specifies if the input should auto-focus.
styleViewStyleOptional. Custom style for the component's container.
inputStyleTextStyleOptional. Custom style for the input fields.
placeholderColorstringOptional. Color for the placeholder text.
placeholders{ number: string; expiry: string; cvc: string; }Optional. Custom placeholders for the input fields.
onChange(formData: CreditCardFormData) => voidRequired. Callback function called when form data changes.
onFocusField(field: CreditCardFormField) => voidOptional. Callback function called when a field gains focus.

CreditCardInput

PropTypeDescription
autoFocusbooleanOptional. Specifies if the input should auto-focus.
styleViewStyleOptional. Custom style for the component's container.
labelStyleTextStyleOptional. Custom style for the labels.
inputStyleTextStyleOptional. Custom style for the input fields.
placeholderColorstringOptional. Color for the placeholder text.
labels{ number: string; expiry: string; cvc: string; }Optional. Custom labels for the input fields.
placeholders{ number: string; expiry: string; cvc: string; }Optional. Custom placeholders for the input fields.
onChange(formData: CreditCardFormData) => voidRequired. Callback function called when form data changes.
onFocusField(field: CreditCardFormField) => voidOptional. Callback function called when a field gains focus.

CardView

PropTypeDescription
focusedField'name' | 'number' | 'expiry' | 'cvc'Optional. Specifies which field is currently focused.
typeCreditCardIssuerOptional. Specifies the type of the credit card issuer.
namestringOptional. The name on the credit card.
numberstringOptional. The credit card number.
expirystringOptional. The expiry date of the credit card.
cvcstringOptional. The CVC code of the credit card.
placeholders{ number: string; expiry: string; cvc: string; name: string; }Optional. Custom placeholders for the input fields.
styleViewStyleOptional. Custom style for the component's container.
fontFamilystringOptional. Custom font family for the text.
imageFrontImageSourcePropTypeOptional. Image source for the front of the credit card.
imageBackImageSourcePropTypeOptional. Image source for the back of the credit card.
android
component
credit-card
ios
payment
react-native

sbycrosz/react-native-credit-card-input

Easy, cross-platform credit-card input for your React Native Project! Start accepting payment πŸ’° in your app today!

TypeScript

1,508

14 commits

updated Nov 10, 2025

See the code

README

React Native Credit Card Input - Finally updated in 2024!

Example on Expo Snack - Easy (and good looking) credit-card input for your React Native Project πŸ’³ πŸ’³

Code:

<CreditCardInput />
// or
<LiteCreditCardInput />

Features

  • Skeuomorphic credit-card πŸ’³
  • Lite version for smaller screens / compact layout
  • Credit-card input validations & formatting while you're typing
  • Form is fully navigatable using keypad
  • Works on both Android, iOS and Web!

Usage

yarn add react-native-credit-card-input

then add these lines in your react-native codebase

import { CreditCardInput, LiteCreditCardInput } from "react-native-credit-card-input";

<CreditCardInput onChange={_onChange} />
// or
<LiteCreditCardInput onChange={_onChange} />

// Note: You'll need to enable LayoutAnimation on android to see LiteCreditCardInput's animations
// UIManager.setLayoutAnimationEnabledExperimental(true);

And then on your onChange handler:

_onChange => form => console.log(form);

// will print:
{
  valid: true, // will be true once all fields are "valid" (time to enable the submit button)
  values: { // will be in the sanitized and formatted form
  	number: "4242 4242",
  	expiry: "06/19",
  	cvc: "300",
  	type: "visa", // will be one of [null, "visa", "master-card", "american-express", "diners-club", "discover", "jcb", "unionpay", "maestro"]
  },
  status: {  // will be one of ["incomplete", "invalid", and "valid"]
	number: "incomplete",
	expiry: "incomplete",
	cvc: "incomplete",
  },
};

Example

Expo Snack

Or run it locally

yarn install

yarn example ios
# or
yarn example android
# or
yarn example web

Should I used this in my project?

  • Yes, if you need a quick credit card input component for your project or proof of concept.
  • Yes, if the current UI/component fit your use case
  • Otherwise, you're probably better off using your favorite form library and implementing the validation with the card-validator package!

Components

LiteCreditCardInput

PropTypeDescription
autoFocusbooleanOptional. Specifies if the input should auto-focus.
styleViewStyleOptional. Custom style for the component's container.
inputStyleTextStyleOptional. Custom style for the input fields.
placeholderColorstringOptional. Color for the placeholder text.
placeholders{ number: string; expiry: string; cvc: string; }Optional. Custom placeholders for the input fields.
onChange(formData: CreditCardFormData) => voidRequired. Callback function called when form data changes.
onFocusField(field: CreditCardFormField) => voidOptional. Callback function called when a field gains focus.

CreditCardInput

PropTypeDescription
autoFocusbooleanOptional. Specifies if the input should auto-focus.
styleViewStyleOptional. Custom style for the component's container.
labelStyleTextStyleOptional. Custom style for the labels.
inputStyleTextStyleOptional. Custom style for the input fields.
placeholderColorstringOptional. Color for the placeholder text.
labels{ number: string; expiry: string; cvc: string; }Optional. Custom labels for the input fields.
placeholders{ number: string; expiry: string; cvc: string; }Optional. Custom placeholders for the input fields.
onChange(formData: CreditCardFormData) => voidRequired. Callback function called when form data changes.
onFocusField(field: CreditCardFormField) => voidOptional. Callback function called when a field gains focus.

CardView

PropTypeDescription
focusedField'name' | 'number' | 'expiry' | 'cvc'Optional. Specifies which field is currently focused.
typeCreditCardIssuerOptional. Specifies the type of the credit card issuer.
namestringOptional. The name on the credit card.
numberstringOptional. The credit card number.
expirystringOptional. The expiry date of the credit card.
cvcstringOptional. The CVC code of the credit card.
placeholders{ number: string; expiry: string; cvc: string; name: string; }Optional. Custom placeholders for the input fields.
styleViewStyleOptional. Custom style for the component's container.
fontFamilystringOptional. Custom font family for the text.
imageFrontImageSourcePropTypeOptional. Image source for the front of the credit card.
imageBackImageSourcePropTypeOptional. Image source for the back of the credit card.
android
component
credit-card
ios
payment
react-native

Project health

Overall

2.8/10

Maintained

0/10

Code review

0/10
OpenSSF Scorecard

Latest release

1.0.0 Β· Jul 19, 2024

Releases this year

0

Significant stargazers

Hayden Bleasel

1,552 followers Β· starred Mar 2021

Ali Abbas

189 followers Β· starred Nov 2019

Matheus Filype

133 followers Β· starred Aug 2023

beezee

41 followers Β· starred Sep 2016