Xzero UI
Pro library

Money input

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

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/money-input
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/money-input

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { useState } from "react";
import { MoneyInput } from "@/components/xzero/money-input/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]}
    />
  );
}

API reference

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
label (required)string–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.

Keyboard interactions

KeysAction
ArrowUp / ArrowDownAdds or subtracts one step (one major unit by default).
Shift+ArrowUp / Shift+ArrowDownMoves ten steps.
PageUp / PageDownMoves ten steps.
EnterSettles the fraction, such as 12.5 to 12.50.
Backspace / DeleteOver a group separator, deletes the digit beside it.
ArrowDown / ArrowUp (on the currency button)Opens the currency menu.
ArrowDown / ArrowUp / Home / End (in the menu)Moves through currencies; typing jumps by code or name.
Enter / Space (in the menu)Picks the highlighted currency.
Escape (in the menu)Closes the menu and returns to the button.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in special inputs

Guidance for AI tools

Money input: A currency field with live grouping, stable width, rolling digits, and minor-unit output. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components