ComponentsForms & inputs

Amount picker

Pick an amount to give or pay: preset amounts with an impact line for the chosen one, an "Other amount" currency field with bounds, and a one-off / monthly switch (or your own frequencies) that can swap the presets. Donations, tips, top-ups, gift cards and pledges.

components/amount-picker.tsxtheme · material · accent · density · font
How often
Amount
$200 a monthKeeps one reading room open an extra evening a month.

Installation

$ pnpm add @vamos-ui/react

The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";

Usage

import { AmountPicker } from "@vamos-ui/react";

<AmountPicker
  amounts={(frequency) => (frequency === "monthly" ? monthlyAmounts : oneOffAmounts)}
  min={50}
  name="amount"
  frequencyName="frequency"
/>

Frequency and amount are radio groups (one tab stop each); the summary and impact line are a polite live region.

State the recurring charge plainly before payment — amount, frequency, first charge and how to cancel.

Examples

Own frequencies, computed impact

frequencies with a suffix for the summary, bounds on the custom amount and an impact function for any amount.

How often
Top up by
$20 onceAbout 8 rides at the standard fare.

API

AmountPicker

PropTypeDefault
amounts
{ value, impact?, badge? }. A function swaps the presets per frequency.
AmountOption[] | (frequency) => AmountOption[]—
frequencies
{ id, label, suffix? }. suffix ("a month") turns the summary recurring. false hides the switch.
AmountFrequency[] | falseone-off, monthly
value / defaultValue / onValueChange
The choice.
{ amount: number | null, frequency }—
allowCustom / min / max
"Other amount" with a currency field; bounds are checked and explained.
boolean / numbertrue
impact
Impact line for any amount. Default: the largest preset at or below it.
(amount, frequency) => ReactNode—
currency
Default: the provider currency.
string—
name / frequencyName / form
Hidden fields (amount empty while out of bounds).
string—
columns
Preset columns.
2 | 3 | 43
labels
Dictionary namespace "amountPicker": frequency, once, monthly, amount, custom, customInput, summaryOnce, summaryRecurring, perMonth, min, max, empty.
Partial<AmountPickerLabels>—

impactFor(options, amount)

PropTypeDefault
returns
The impact of the largest preset at or below the amount.
ReactNode—