CreditCard
A card that tilts toward the pointer and flips to its back. The number is masked down to the last four digits. Finance.
Open playgroundAbout
CreditCard 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 { CreditCard } from "@ashutoshswamy/smoui" and set number, name, cvc among its 4 props.
Install
npm i @ashutoshswamy/smouiUsage
import { CreditCard } from "@ashutoshswamy/smoui";
<CreditCard number="4242 4242 4242 8431" name="Ada Lovelace" expiry="09/29" cvc="418" />Props 4
- number
Only the last four digits show unless reveal is set.
string- name / expiry
Cardholder and MM/YY.
string- cvc
Shown on the back.
string- reveal
Show the whole number. Default false.
boolean
More finance components
- AmountInputA big amount field. Digits group as you type, the figure shakes and turns red past your balance, and chips add to it or fill the max.
- BalanceChartBalance over time. Switch the range and the line morphs; drag across it and the figure follows with the change since the start.
- CandlestickChartCandles that grow from their middle when scrolled into view. Point at one: the rest dim and a readout gives open, high, low and close.
- CardFormA 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.
- CurrencySwapA two-way converter. Type an amount and the result eases to its value; the swap button turns the pair around.
- ExchangeRateChip"1 USD = 0.9214 EUR" as a chip. The rate eases to each update, the chip washes green or red for a beat, and a change pill turns with its sign.