Money input

A currency field with live grouping, stable width, rolling digits, and minor-unit output.

npm install https://animui.stracture.net/__local/package.tgz
Live · keyboard ready

Pay Jasmine Brooks

Studio lunch, Thursday

$1.00 to $2,480.00
Arrow keys step by 1, Shift by 10
  • Payment, tip, transfer, or budget amounts entered by hand.
  • Invoice and expense forms where the currency may change.
  • Amount fields that benefit from quick add chips such as +$10.
  • Use number-field for quantities and non currency numbers.
  • Use slider or price-ladder when people pick from a range rather than type.
  • Use scrub-input for design tool style drag adjustments.

Installation

Install animui once, then import any component or block from its typed package entry.

animui · 250 components and blocks

React 19 and React DOM 19 are required. The package includes Free and Pro entries, styles and TypeScript declarations.

npm install https://animui.stracture.net/__local/package.tgz

Load the stylesheet once at your app root, then use the typed component import:

import 'animui/styles.css';
import { MoneyInput } from 'animui/money-input';

Read the Code tab for the implementation files and the API reference below for required props.

Download animui 0.3.0 · Agent guide
example.tsx
import { useState } from "react";import { MoneyInput } from "animui/money-input"; export function TipAmount() {  const [cents, setCents] = useState<number | null>(1500);  return (    <MoneyInput      label="Amount"      name="amount"      value={cents}      onValueChange={setCents}      currencies={["USD"]}      min={100}      max={100_000}      quickAdd={[5, 10, 20]}    />  );}

MoneyInput

A currency amount field that groups digits as you type, holds missing cents as ghosts, scales long amounts to fit, and returns minor units.

PropTypeDefaultDescription
labelRequiredstring–Field label.
hideLabelbooleanfalseKeeps the label for screen readers only.
valuenumber | null–Controlled amount in minor units (cents for USD, yen for JPY). null is empty.
defaultValuenumber | nullnullStarting amount in minor units when uncontrolled.
onValueChange(value: number | null, details: MoneyInputDetails) => void–Called with minor units and { currency, major, formatted }.
currencystring–Controlled ISO 4217 code, such as "USD".
defaultCurrencystring"USD"Starting currency when uncontrolled.
onCurrencyChange(currency: string) => void–Called when a currency is picked. The major amount carries over.
currenciesstring[]["USD", "EUR", "GBP", "JPY", "CAD", "AUD", "CHF", "INR"]Codes in the currency menu. Pass one code to hide the menu.
minnumber–Lowest amount in minor units. Checked when the field loses focus.
maxnumber–Highest amount in minor units. Typing past it is refused with a nudge.
quickAddnumber[][10, 50, 100]Quick add chips in major units. Pass an empty array to hide them.
stepnumber–Arrow keys move by this many minor units. Defaults to one major unit; Shift moves ten times as far.
localestring"en-US"Formatting locale. Fixed by default so server and client render the same digits.
descriptionstring–Hint under the field.
errorstring–Replaces the built-in range message.
disabledbooleanfalseDisables the field, menu, and chips.
namestring–Adds a hidden input carrying the amount in minor units.
idstring–Id of the input.
classNamestring–Class on the root.
onBlur(event: FocusEvent<HTMLInputElement>) => void–Called when the input loses focus, after the fraction settles.
refRef<HTMLInputElement>–Forwarded to the input.
ArrowUporArrowDown
Adds or subtracts one step (one major unit by default).
Shift+ArrowUporShift+ArrowDown
Moves ten steps.
PageUporPageDown
Moves ten steps.
Enter
Settles the fraction, such as 12.5 to 12.50.
BackspaceorDelete
Over a group separator, deletes the digit beside it.
ArrowDownorArrowUp (on the currency button)
Opens the currency menu.
ArrowDownorArrowUporHomeorEnd (in the menu)
Moves through currencies; typing jumps by code or name.
EnterorSpace (in the menu)
Picks the highlighted currency.
Escape (in the menu)
Closes the menu and returns to the button.
  • The input has role="spinbutton" with aria-valuenow in major units, aria-valuetext as the full currency string, and min and max when set.
  • The animated digits are aria-hidden; the real input carries the value, so screen readers and autofill see plain text.
  • The range, hint, and error are linked with aria-describedby; limits, chip adds, and currency changes are announced politely.
  • The currency menu is a listbox with aria-activedescendant and typeahead.
  • Chips and arrow keys roll each digit column in the direction of change while new columns open their width; typing cuts straight to the result so the caret never lags.
  • A refused change kicks the amount sideways on a bouncy spring and flashes the range.
  • The currency symbol swaps with a short roll while its slot springs to the new width; long amounts scale down to fit on a spring.
  • Reduced motion removes the rolls, kick, and width springs; digits fade and sizes jump.
  • Under 420px viewport width the amount text drops a size and the padding tightens.
  • A ResizeObserver scales the amount down to fit its box instead of scrolling, so long numbers stay readable on phones.
  • inputMode is decimal (numeric for zero decimal currencies like JPY), which brings up the number keypad on touch.
  • Intl.NumberFormat instances are cached per locale and currency.
  • Each digit is its own animated column; amounts are capped at 12 integer digits, which keeps the column count small.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

  • Store the value in minor units (integers) to avoid floating point errors; details.major and details.formatted are for display.
  • Use for money only. For plain numbers with units use number-field, and for drag-to-adjust values use scrub-input.
  • Pass one code in currencies to lock the currency; the code then shows as static text.
  • max refuses typing past it; min is only checked on blur, so people can type through smaller amounts on the way.

The full library index for assistants is at /llms.txt.