Lion Logo Lion Guides Components Docs Blog Toggle darkmode

Localize: Format Numbers

Features

  • Small file size
  • Uses Intl.NumberFormat but patches browser inconsistencies

Formatting

With the formatNumber you can safely display a number for all languages.

The input value is 1234.56.

Formatting parts

formatNumberToParts allows to get individual parts of a number on all browsers.

The input value 1234.56 gets formatted via

formatNumberToParts(value, { style: 'currency', currency: 'EUR' });

List common locales

The input value is 1234.56. Formatting happens via

formatNumber(1234.56, { locale, style: 'currency', currency: 'EUR' });
formatNumber(1234.56, { locale, style: 'currency', currency: 'USD' });

List all locales

The following list show number formatting for all known locales.

The input value is 1234.56. Formatting happens via

formatNumber(1234.56, { locale, style: 'currency', currency: 'EUR' });
formatNumber(1234.56, { locale, style: 'currency', currency: 'USD' });