ComponentsForms & inputs
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
| Prop | Type | Default |
|---|---|---|
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[] | false | one-off, monthly |
value / defaultValue / onValueChangeThe choice. | { amount: number | null, frequency } | — |
allowCustom / min / max"Other amount" with a currency field; bounds are checked and explained. | boolean / number | true |
impactImpact line for any amount. Default: the largest preset at or below it. | (amount, frequency) => ReactNode | — |
currencyDefault: the provider currency. | string | — |
name / frequencyName / formHidden fields (amount empty while out of bounds). | string | — |
columnsPreset columns. | 2 | 3 | 4 | 3 |
labelsDictionary namespace "amountPicker": frequency, once, monthly, amount, custom, customInput, summaryOnce, summaryRecurring, perMonth, min, max, empty. | Partial<AmountPickerLabels> | — |
impactFor(options, amount)
| Prop | Type | Default |
|---|---|---|
returnsThe impact of the largest preset at or below the amount. | ReactNode | — |