CardForm

A payment card that fills in as you type. Digits group themselves, the brand is read from the first numbers, the number is checked with Luhn, and the card turns over when you reach the CVC. Finance.

Open playground

About

CardForm is a React component in the Finance category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { CardForm } from "@ashutoshswamy/smoui" and set onSubmit, cta.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { CardForm } from "@ashutoshswamy/smoui";

<CardForm cta="Pay $190.00" onSubmit={(card) => charge(card)} />

Props 2

onSubmit

Called with the digits once the card is valid. Return a promise to show the loading state.

(values) => void | Promise
cta

Button label.

stringdefault "Pay now"