PaymentMethodPicker
Saved ways to pay as one radio group. A highlight glides to the pick, arrows move between methods, and expired ones are skipped. Finance.
Open playgroundAbout
PaymentMethodPicker 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 { PaymentMethodPicker } from "@ashutoshswamy/smoui" and set methods, label, value among its 5 props.
Install
npm i @ashutoshswamy/smouiUsage
import { PaymentMethodPicker } from "@ashutoshswamy/smoui";
<PaymentMethodPicker
label="Pay with"
methods={[
{ id: "visa", kind: "card", title: "Visa", detail: "•••• 4242", note: "Expires 08/27" },
{ id: "chase", kind: "bank", title: "Chase checking", detail: "Account ending 0912" },
]}
onChange={setMethod}
onAdd={openAddFlow}
/>Props 5
- methods
Each has id, kind (card, bank or wallet), title, detail, an optional note on the right, and disabled.
PaymentMethod[]- label
Accessible name for the group.
string- value / defaultValue / onChange
The chosen method id.
string- onAdd
Adds a last row. Leave it out to hide the row.
() => void- addLabel
Text of that row.
stringdefault"Add payment method"
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.
- CreditCardA card that tilts toward the pointer and flips to its back. The number is masked down to the last four digits.
- CurrencySwapA two-way converter. Type an amount and the result eases to its value; the swap button turns the pair around.