Skip to the content

InputCurrency

InputCurrency is an Input for money. It groups thousands and limits decimals to two as the user types, and pads the decimals with 00 on blur. onChange receives the formatted string without the prefix (1.234,50), debounced by 250 ms.
Forms

When to use

Use when
  • Collecting a price, salary or any amount in one currency.
  • The user should see separators appear while typing.
Avoid when
  • The number has no unit — use Input with type="number".
  • The value has a fixed digit pattern — use InputMask.

Usage

<InputCurrency aria-label="Amount" prefix="R$" onChange={setAmount} />

Defaults are decimal=",", thousand="." and prefix="R$". A numeric value is converted with the pt-BR locale; a new value prop is re-formatted, so a Form reset() updates the field. Keep the separators fixed once the user has typed.

Converting to a number

currencyToNumber(text, decimalChar) turns the formatted string back into a number:

import { currencyToNumber } from '@apollion-dsi/core/form/input-currency';

currencyToNumber('1.234,50', ','); // 1234.5

Ticket with chips

suffix prints a unit at the right edge. options attaches an Option row flush under the input; optionValue and onOptionChange control it. The chips do not change the amount — map the pick in your handler.

BRL
<InputCurrency
  aria-label="Amount to spend"
  suffix="BRL"
  options={[
    { value: '25', label: '25%' },
    { value: '100', label: 'Max' },
  ]}
  optionValue={pct}
  onOptionChange={applyFraction}
  onChange={setAmount}
/>

Accessibility

  • InputCurrency renders no label: use Field or pass aria-label.
  • The chip row is a radiogroup named by optionsLabel (default Percent of balance); rename it for other uses.

Properties

See also