Currency Input
Money field with a currency selector and live thousand/decimal formatting.
Import
import { CurrencyInput } from "@cooud-ui/ui";
npx cooud-ui add currency-input
Examples
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>`. |