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
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.5Ticket 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
InputCurrencyrenders no label: useFieldor passaria-label.- The chip row is a
radiogroupnamed byoptionsLabel(defaultPercent of balance); rename it for other uses.
Properties
Name
Type
Default
Description
clearablebooleannoneShows a clear button ("×" icon) when there is a value. Requires `reset`
to work outside a `Form`.
clearLabelstring'Limpar'Accessible name of the clear button (`clearable`) — it shows only an icon.
decimalstring','Decimal separator.
iconanynoneReact element rendered inside the input (usually an `<Icon />`).
When set, the input automatically makes room to avoid collision
with the typed text.
@example ```tsx
<Input icon={<Icon icon={search} />} iconPosition="left" />
```
iconPosition"right""left"'right'Side on which the icon (`icon` or the clear button) is rendered.
onChange((value: string) => void)noneCallback (debounced 250 ms) with the formatted string (including prefix).
onOptionChange((value: string) => void)noneFired with the picked chip value.
optionsOptionItem<string>[]noneTicket variant: a compact `Option` row (percent-of-balance chips, for
instance) attached flush under the control — one Field-sized stack, no
second form gap. Pair with `optionValue` / `onOptionChange`.
@example ```tsx
<InputCurrency
options={[{ value: '25', label: '25%' }, { value: '50', label: '50%' }, { value: '100', label: 'Max' }]}
optionValue={pct}
onOptionChange={applyFraction}
/>
```
optionsLabelstring'Percent of balance'Accessible name of the chip row (`aria-label` on the `radiogroup`).
optionValuestringnoneSelected chip of `options`.
prefixstring'R$'Currency unit prefix.
reset(() => void)noneCallback invoked when the user clicks the clear button (`clearable`).
Inside a `Form`, it is injected automatically; in standalone use, it
must clear the controlled state.
size"expansive""medium""compact""micro"'medium'Size token of the input.
suffixstringnoneUnit shown inside the control, at the right edge (an asset ticker, a
unit). Inert text; the input reserves room for it like the icon slot.
@example ```tsx
<InputCurrency prefix="R$" suffix="BRL" />
```
thousandstring'.'Thousands separator.
valuestringnumbernoneInitial value — `number` is converted to `string` using `pt-BR`.
variant"default""success""error"'default'Visual variant of the input — reflects the validation state.