Currency Input
Money field with a currency selector and live thousand/decimal formatting.
Import
import { CurrencyInput } from "@cronus-ui/ui";
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.
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" >
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | null | — | Controlled amount in **minor units** (integer cents). Use `null` for empty. Pair with `onValueChange`. |
defaultValue | number | null | null | Initial 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 | number | 0 | Lower 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 | boolean | false | Marks the field invalid (red border + `aria-invalid`). |
disabled | boolean | false | Disables 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. |