Money input
A currency field with live grouping, stable width, rolling digits, and minor-unit output.
npx shadcn@latest add @silicon-ui/money-inputInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/money-inputManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/money-input/money-input.tsx
- components/silicon-ui/money-input/money-input.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/lib/fluid-hover.tsx
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
label* | string | — |
hideLabel | boolean | false |
valueAmount in minor units (cents for USD, yen for JPY). `null` is empty. | number | null | — |
defaultValue | number | null | null |
onValueChange | (value: number | null, details: MoneyInputDetails) => void | — |
currencyISO 4217 code, such as "USD". | string | — |
defaultCurrency | string | "USD" |
onCurrencyChange | (currency: string) => void | — |
currenciesCodes offered by the currency menu. Pass one code to hide the menu. | string[] | ["USD", "EUR", "GBP", "JPY", "CAD", "AUD", "CHF", "INR"] |
minLowest amount in minor units. Checked when the field loses focus. | number | — |
maxHighest amount in minor units. Typing past it is refused with a nudge. | number | — |
quickAddQuick add chips in major units. Pass an empty array to hide them. | number[] | [10, 50, 100] |
stepArrow keys move by this many minor units. Defaults to one major unit; Shift moves ten times as far. | number | — |
localeFormatting locale. Fixed by default so server and client render the same digits. | string | "en-US" |
description | string | — |
errorReplaces the built-in range message. | string | — |
disabled | boolean | false |
nameAdds a hidden input carrying the amount in minor units. | string | — |
id | string | — |
className | string | — |
onBlur | (event: ReactFocusEvent<HTMLInputElement>) => void | — |
Also accepts the props of HTMLAttributes.
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens