API reference / @localizer/format-number / NumberFormatOptions
Type Alias: NumberFormatOptions
NumberFormatOptions =
object
Defined in: options.ts:25
Options for formatting numbers using Intl.NumberFormat
. Supports customization for locale, style, currency, unit, grouping, significant digits, rounding, and more.
Properties
Property | Modifier | Type | Description |
---|---|---|---|
compactDisplay? | public | "short" | "long" | Specifies the compact number format. - 'short': Abbreviated form (e.g., 1K for 1000). - 'long': Full form (e.g., 1 thousand for 1000). |
currency? | public | CurrencyCode | ISO 4217 currency code (e.g., 'USD', 'EUR'). Required if style is 'currency'. |
currencyDisplay? | public | "symbol" | "narrowSymbol" | "code" | "name" | Specifies how the currency is displayed. - 'symbol': Currency symbol (e.g., '$'). - 'narrowSymbol': Narrower currency symbol. - 'code': ISO currency code (e.g., 'USD'). - 'name': Full currency name (e.g., 'US Dollar'). |
currencySign? | public | "standard" | "accounting" | Specifies the currency sign format. - 'standard': Standard currency sign. - 'accounting': Accounting currency sign. |
localeMatcher? | public | "lookup" | "best fit" | Specifies the locale for formatting. Defaults to the runtime's locale if omitted. |
maximumFractionDigits? | public | number | Maximum fraction digits in the output. Defaults to runtime environment settings. |
maximumSignificantDigits? | public | number | Maximum significant digits in the output. Defaults to runtime environment settings. |
minimumFractionDigits? | public | number | Minimum fraction digits in the output. Defaults to runtime environment settings. |
minimumIntegerDigits? | public | number | Minimum integer digits in the output. Defaults to runtime environment settings. |
minimumSignificantDigits? | public | number | Minimum significant digits in the output. Defaults to runtime environment settings. |
notation? | public | "standard" | "scientific" | "engineering" | "compact" | Specifies the number notation. - 'standard': Standard formatting. - 'scientific': Scientific notation. - 'engineering': Engineering notation. - 'compact': Compact representation. |
numberingSystem? | public | string | Specifies the numbering system for formatting. Examples: 'latn' (Latin), 'arab' (Arabic). |
parts? | public | (Intl.NumberFormatPartTypes | `${"startRange" | "endRange" | "shared"}-${Intl.NumberFormatPartTypes}`)[] | Specifies parts to include in the formatted output. Examples: 'currency', 'group', 'integer', 'literal', 'minusSign', 'nan', 'percentSign', 'plusSign', 'unit'. |
roundingIncrement? | public | 1 | 2 | 5 | 10 | 20 | 25 | 50 | 100 | 200 | 250 | 500 | 1000 | 2000 | 2500 | 5000 | Specifies the rounding increment for formatting. Examples: 1, 2, 5, 10, etc. Defaults to runtime environment settings if omitted. |
roundingMode? | public | "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | Specifies the rounding mode for number formatting. Options include: - 'ceil': Round up. - 'floor': Round down. - 'expand': Round away from zero. - 'trunc': Truncate towards zero. - 'halfCeil': Round half up. - 'halfFloor': Round half down. - 'halfExpand': Round half away from zero. - 'halfTrunc': Round half towards zero. - 'halfEven': Round to nearest even number. |
roundingPriority? | public | "auto" | "morePrecision" | "lessPrecision" | Determines rounding priority. - 'auto': Default behavior. - 'morePrecision': Favors precision. - 'lessPrecision': Favors simplicity. |
signDisplay? | public | "auto" | "never" | "always" | "exceptZero" | "negative" | Controls how the sign is displayed. - 'auto': Default behavior. - 'never': No sign. - 'always': Always show the sign. - 'exceptZero': Show sign except for zero. - 'negative': Only for negative values. |
style? | public | "decimal" | "currency" | "percent" | "unit" | Defines the formatting style. - 'decimal': Standard decimal numbers. - 'currency': Currency values. - 'percent': Percentages. - 'unit': Numbers with specific units (e.g., meters, kilograms). |
trailingZeroDisplay? | public | "auto" | "stripIfInteger" | Controls the display of trailing zeros. - 'auto': Default behavior. - 'stripIfInteger': Removes zeros for integer values. |
unit? | public | Unit | Specifies the unit for formatting when style is 'unit'. Example: 'meter', 'kilogram'. Required if style is 'unit'. |
unitDisplay? | public | "short" | "long" | "narrow" | Specifies how the unit is displayed. - 'short': Abbreviated (e.g., 'm' for meters). - 'long': Full name (e.g., 'meter'). - 'narrow': Minimal form. |
useGrouping? | public | "auto" | "always" | "min2" | true | false | Defines the percentage formatting style. - 'standard': Standard percentage format. - 'scientific': Scientific notation. - 'engineering': Engineering notation. - 'compact': Compact representation. |