AmountInput
The hardest input in fintech.
npx shadcn add @lopifi/amount-inputExamples
The same component, case by case. Each stage is the shipped code with the props it shows; switch to Code for the usage.
How it behaves
What it renders, what it refuses to render, and why. The same paragraphs as the family spec, so the two can’t disagree.
The hardest input in fintech. If this is wrong, nothing else matters.
<AmountInput
currency="USD"
value={amount}
onChange={setAmount}
max={availableBalance}
onMaxClick={() => setAmount(availableBalance)}
/>
The rules#
type="text"+inputMode="decimal". Nevertype="number". Its scroll wheel increments the value (and will silently change someone's payment), it parses decimals differently by locale, and its spinners can't be styled.- 16px minimum font size or iOS Safari zooms the viewport on focus and never zooms back.
- Parse permissively, format on blur. Accept
1,234.56,1234,56,1 234.56,$1234.56,1.2k. Reject nothing a person would type. Format canonically when they leave the field. - Never reformat mid-typing. Inserting a thousands separator mid-typing moves the caret. It's the most infuriating input bug in fintech. Format on blur only.
- Caret preservation if you must transform during input — measure the caret offset from the right, not the left.
- Never block paste.
- Locale-aware decimal separator. A German user types
1234,56. Accept it. - Currency-aware precision. JPY rejects decimals entirely; KWD accepts three.
- Max is soft by default. Show "Exceeds available balance of $4,120.00" as an inline error, but let them type it. An overdraft may be legitimate, and blocking input to prevent an invalid state blocks valid ones too. The check — and the Max button — apply only when
maxis in the field's own currency; a balance in another currency is shown but never compared. - Big.
figure-lg(28/32) or larger. It's the most important number on the screen and should look it. - The symbol is part of the field, at
--text-tertiary, not a floating adornment that misaligns as the value grows.
Accessibility#
aria-label="Amount in US dollars" · parsed value announced on blur ("one thousand two hundred thirty-four dollars and fifty-six cents") via aria-describedby · errors specific and actionable · aria-invalid on error.
Motion#
None on the value. Error message: 140ms opacity + 4px translate. Shake on invalid submit is forbidden. It signals stress to a user who's already anxious about money.
The accounting it encodes
The concepts this component renders, each defined once in the lexicon.
More in Payments
See also
Where this component is specified, defined and running.
Elsewhere in the system
The live section AmountInput renders in, the calculators behind its figures, and the ledger payloads that feed it.
- AmountInput, runningThe payments showcase — live, with theme, density, grayscale and reduced-motion switches.
- PaymentsPayments — specs for 14 React components: AmountInput, CurrencySelect, PayeeSelect, PaymentForm and 10 more.
- Currency decimal placesHow many decimals each ISO 4217 code is stored at, and where Intl disagrees.
Components are copied into your repository and meant to be edited. Rounding policy, fiscal calendar and compliance copy differ per company.
Release notes
Get an email when Payments changes
Your copy doesn’t update itself when we fix something here.
- One email when a Payments component needs a migration
- Nothing when nothing changes
Or install it now