Format Number

Shows a number formatted for the reader's language, such as a price, a percent, or a compact count.

1,450.45

Usage

Code
import { FormatNumber } from '@leverui/components';
Code
<FormatNumber value={1000} />

Examples

Percentage

Use the style="percent" prop to change the number format to percentage.

14.50%

Currency

Use the style="currency" prop to change the number format to currency.

$1,234.45

Locale

Wrap the FormatNumber component within the LocaleProvider to change the locale.

de-DE

1.450,45

zh-CN

1,450.45

Unit

Use the style="unit" prop to change the number format to unit.

384.4 km

Compact Notation

Use the notation="compact" prop to change the number format to compact notation.

1.5M

Guides

Output

Renders plain text with no element around it, in the locale of the nearest LocaleProvider. For attributes, styles, or a test selector, wrap it in an element such as span.

For a percentage, set style="percent" and pass a fraction, such as 0.25 for 25%. The value, the options, and the provider's locale can all change at runtime.

For bytes, see Format Byte.

Props

PropDefaultTypeDescription
valueRequirednumberNumber to format.

Also accepts every Intl.NumberFormat option.