React Native MantineTypography

NumberFormatter

Format numbers with separators and affixes

Import: import { NumberFormatter } from 'react-native-mantine';

Usage

import { NumberFormatter } from 'react-native-mantine';

<NumberFormatter
  prefix="$ "
  value={1234567.89}
  thousandSeparator
  decimalScale={2}
/>

// Custom separators
<NumberFormatter
  value={1234567.891}
  thousandSeparator="."
  decimalSeparator=","
  suffix=" EUR"
/>

Props

PropTypeDefaultDescription
valuenumber | stringValue to format. Nothing is rendered if the value is empty or not a valid number
prefixstringPrefix added before the formatted value (e.g., "
quot;)
suffixstringSuffix added after the formatted value (e.g., " USD")
thousandSeparatorstring | booleanThousands separator, true for "," or any string (e.g., " ", ".")
decimalSeparatorstring"."Decimal separator character
decimalScalenumberLimits the number of digits after the decimal point
fixedDecimalScalebooleanfalseIf true, zeros are added to match decimalScale
allowNegativebooleantrueDetermines whether negative values are allowed
styleTextStyleAdditional styles to apply to the rendered text

Source on GitHub · npm