@m3000/marketv0.0.0

Price

Format fiat and crypto prices from smallest-unit integers with `bigint`, precision controls, and customizable rendering.

Installation

pnpm add @m3000/market

Usage

$123.45

Price formats raw smallest-unit values and accepts number, string, and bigint.

Examples

With Abbreviation

Large numbers are automatically abbreviated (K, M, B).

$2.5M

High Decimal Precision

Supports any currency, including those that use high-precision decimal values. For example, Ethereum values may be stored in wei (the smallest unit) and displayed using up to 18 decimal places.

2.45 ETH

Custom Locale

Apply locale-specific grouping and decimal separators with Price.Value.

1.234.567,89 EUR

Customized Rendering

Compose Price.Value and Price.Symbol inside your own layout to control placement, emphasis, and surrounding UI.

Subtotal$12,345.67

Fixed Precision

Combine minDecimals and maxDecimals when you want a stable number of visible decimal places, such as interactive crypto price inputs.

1.825ETHDefault precision adapts to the value
1.8250ETHFixed precision stays stable at 4 decimals

API Reference

Price

The root component that provides context for price formatting.

PropTypeDefaultDescription
valuenumber | bigint | stringrequiredRaw value in the smallest unit to format
decimalsnumberrequiredNumber of decimal places represented by the raw value
minDecimalsnumbernoneMinimum decimal places to display
maxDecimalsnumberdecimalsMaximum decimal places to display
abbreviatebooleanfalseAbbreviate large numbers (K, M, B)

Price.Value

Renders the formatted price value. Pass locale when you want localized separators and grouping.

PropTypeDefaultDescription
localestringnoneLocale for number formatting

Price.Symbol

Renders the currency symbol.

PropTypeDefaultDescription
childrenReactNoderequiredThe symbol to display

On this page