Component size, gzipped: 36kb

Payment Card

API

The Payment Card input automatically detects and formats credit card types. It shows a small thumbnail icon of the parsed credit card brand to let users know they have entered their card in the correct format. The supported credit card brands are listed here:

Card Type
Example Number
American Express
378282246310005
Diners Club
36259600000004
Discover
6011111111111117
ELO
6550000000000001
JCB
3530111333300000
Maestro
6304000000000000
Mastercard
5555555555554444
UnionPay
6246729687894613
Visa
4111111111111111

The card-validator library is used to determine the card format. It's also re-exported from baseui/payment-card as valid in case you need more metadata about the card.

This component is based on the Input component. All of the props you can pass to Input also work on PaymentCard: size, error, positive, disabled, etc. The only exception to this is overrides, which has a slightly different API.

Examples

Basic usage

Default value

Payment form

Card number
Expiration date
CVC

If you'd like to add further validations, check out the card-validator package that Base Web uses under the hood too.

Stateful (uncontrolled) usage

As with many of our components, there is also an uncontrolled version, StatefulPaymentCard, which manages its own state.

API

Payment Card props

Payment Card exports

You can import this module like so:

import {StatefulPaymentCard} from 'baseui/payment-card'

It exports the following components or utility functions:

Input exports

You can import this module like so:

import {StatefulInput} from 'baseui/input'

It exports the following components or utility functions: