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 playground

About

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

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
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"