Payment Card
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:
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
If you'd like to add further validations, check out the card-validator package that Base Web uses under the hood too.
As with many of our components, there is also an uncontrolled version, StatefulPaymentCard, which manages its own state.
Payment Card exports
You can import this module like so:
import {StatefulPaymentCard} from 'baseui/payment-card'
It exports the following components or utility functions:
- StatefulPaymentCard
- StatefulContainer
- PaymentCard
- valid
- SIZE
- StyledIconWrapper