Skip to content
Forms

Currency Input

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

Import

tsx
import { CurrencyInput } from "@cooud-ui/ui";
bash
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" >

PropTypeDefaultDescription
value
number | nullControlled 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) => voidFired 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
stringControlled active currency code. Pair with `onCurrencyChange`.
defaultCurrency
stringInitial active currency code for uncontrolled usage. Defaults to the first `currencies` entry.
onCurrencyChange
(code: string, meta: CurrencyInputMeta) => voidFired 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
numberUpper 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
stringExtra classes for the underlying `<input>`.