Components/Currency Converter
Currency Converter
FX conversion field built on MoneyInput: edit the source amount, read the converted one, swap directions. The rate is a prop - plug in your FX feed and re-render as it ticks.
BRL
1 BRL = US$ 0,19
USD
Installation
npx @ajax-ui/cli add currency-converterProps
rate(required) - price of 1 unit offromCurrencyintoCurrency. The component never fetches; rates are your data layer's job.fromCurrency/toCurrency- ISO 4217 (default BRL → USD).defaultAmountCents- initial source amount in minor units.allowSwap(defaulttrue) - flips direction using1/rateand resets the amount.onAmountChange(fromCents, toCents)- both sides in integer minor units.
Precision
Amounts travel as integer minor units end to end; the conversion crosses major units once and rounds once, so zero-decimal currencies (JPY) scale correctly. The converted side is a read-only <output> - a quote, not an editable field, because two editable sides bound by a rounding rate can never stay mutually consistent.