Format Presets
presets is a collection of named Intl.NumberFormatOptions objects for the
most common number formatting patterns. Pass them directly as formatOptions.
Import
Section titled “Import”import { presets } from "raqam";// orimport { presets } from "raqam/core";import { presets } from "raqam";
<NumberField.Root formatOptions={presets.currency("USD")} locale="en-US" /><NumberField.Root formatOptions={presets.percent} locale="en-US" /><NumberField.Root formatOptions={presets.compact} locale="en-US" />Reference
Section titled “Reference”presets.currency(code)
Section titled “presets.currency(code)”presets.currency("USD")// → { style: "currency", currency: "USD" }Standard currency formatting. Shows symbol + thousands separators.
| Locale | Value | Formatted |
|---|---|---|
| en-US | 1234.56 | $1,234.56 |
| de-DE | 1234.56 | 1.234,56 € |
| ja-JP | 1234 | ¥1,234 |
| fa-IR | 1234 | ۱٬۲۳۴ ﷼ |
presets.accounting(code)
Section titled “presets.accounting(code)”presets.accounting("USD")// → { style: "currency", currency: "USD", currencySign: "accounting" }Like currency but shows negative values in parentheses: (1,234.56).
raqam automatically parses (...) back to a negative number.
presets.percent
Section titled “presets.percent”presets.percent// → { style: "percent" }Formats 0.42 as "42%". Store values as decimals (0–1 range).
presets.compact
Section titled “presets.compact”presets.compact// → { notation: "compact" }Short compact notation: 1,200,000 → "1.2M".
presets.compactLong
Section titled “presets.compactLong”presets.compactLong// → { notation: "compact", compactDisplay: "long" }Long compact notation: 1,200,000 → "1.2 million".
presets.scientific
Section titled “presets.scientific”presets.scientific// → { notation: "scientific" }Scientific notation: 1234567 → "1.234567E6".
presets.engineering
Section titled “presets.engineering”presets.engineering// → { notation: "engineering" }Engineering notation (exponent always a multiple of 3): 12345 → "12.345E3".
presets.integer
Section titled “presets.integer”presets.integer// → { maximumFractionDigits: 0 }No decimal places. 1234.5 → "1,235" (rounds).
presets.financial
Section titled “presets.financial”presets.financial// → { minimumFractionDigits: 2, maximumFractionDigits: 2 }Always two decimal places. Combine with fixedDecimalScale prop to force
0.00 when empty.
presets.unit(unit)
Section titled “presets.unit(unit)”presets.unit("kilometer")// → { style: "unit", unit: "kilometer" }Unit formatting. Any CLDR unit identifier works: "kilometer",
"liter", "celsius", "kilometer-per-hour", etc.
Composing with your own options
Section titled “Composing with your own options”Presets are plain objects — spread them to override:
// Compact currency (not standard but possible)const compactCurrency = { ...presets.compact, style: "currency" as const, currency: "USD",};