CurrencyField

Displays a monetary value using Intl.NumberFormat.

Installation

pnpm dlx shadcn@latest add @shadmin/currency-field

Usage

import { CurrencyField } from '@/components/admin';
 
<CurrencyField source="price" currency="USD" />
<CurrencyField source="price" currency="EUR" displayLocale="de-DE" />
<CurrencyField source="price" currency="USD" storeAsMinorUnits />

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-Record field to read
currencyOptional*string-ISO-4217 code (required for plain-number storage)
displayLocaleOptionalstringApp localeOverride formatting locale
storeAsMinorUnitsOptionalbooleanfalseDivide by 100 before formatting
optionsOptionalIntl.NumberFormatOptions-Extra Intl.NumberFormat options
emptyOptionalReactNode-Fallback when value is null
classNameOptionalstring-CSS class on <span>

* currency is required when the source holds a plain number; not required when the source holds { amount, currency }.

Storage shapes

Either a plain number ({ price: 1234.5 } with currency prop), a composite object ({ price: { amount, currency } }), or integer minor units (\{ price: 123450 \} with storeAsMinorUnits).