Skip to content
Forms

Currency Input

Money field with a currency selector and live thousand/decimal formatting.

Import

tsx
import { CurrencyInput } from "@cronus-ui/ui";
bash
npx cronus-ui add currency-input

Examples

.cronus

The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.

PortedParity: MatchGeometry 1/1Pixel diff 0 pxLogic 1/1Parity scoreboard
default.cronus
app "audit-fixtures" {
  port 5176
}

style {
  preset aurora
  theme dark
}

component CurrencyInputDefault layout:inline style:currency-input {
  value:12345
  aria-label:"Amount"
  label "Amount"
}

page "/audit/currency-input/default" type:custom {
  use CurrencyInputDefault
}

API Reference

Generated from the component's exported types.

CurrencyInputProps

Extends Omit< InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "min" | "max" | "type" >

Skip CurrencyInputProps props table
PropTypeDefaultDescription
value
number | null—Controlled amount in **minor units** (integer cents). Use `null` for empty. Pair with `onValueChange`.
defaultValue
number | nullnullInitial amount in minor units for uncontrolled usage. Defaults to `null` (empty).
onValueChange
(value: number | null, meta: CurrencyInputMeta) => void—Fired on every edit with the amount in **minor units** (`null` when cleared) plus formatting `meta`.
currencies
CurrencyOption[]—Selectable currencies. Defaults to BRL, USD and EUR. A single entry renders a static (non-interactive) prefix.
currency
string—Controlled active currency code. Pair with `onCurrencyChange`.
defaultCurrency
string—Initial active currency code for uncontrolled usage. Defaults to the first `currencies` entry.
onCurrencyChange
(code: string, meta: CurrencyInputMeta) => void—Fired when the user picks a different currency (also re-fires `onValueChange` with the new `meta`).
min
number0Lower clamp in minor units, enforced on blur. Defaults to `0` (no negatives).
max
number—Upper clamp in minor units — a hard live ceiling the value can never be typed past.
invalid
booleanfalseMarks the field invalid (red border + `aria-invalid`).
disabled
booleanfalseDisables the field and the currency selector.
selectorLabel
string"Select currency"Accessible name for the currency selector button.
inputClassName
string—Extra classes for the underlying `<input>`.
placeholder
string—Placeholder shown when the value is empty.
name
string—Submitted name when used in a form.
required
boolean—Marks the control as required.
className
string—Additional class names merged onto the root.