Skip to content

Decimals

Set how many decimal places are allowed and which separators the input uses.

decimalMinLength: 2

Padded when the field loses focus

Precision limits

Max decimal places

Try typing more than 2 decimal places. Extra typed digits are refused, and pasted ones are cut off, not rounded (the default limit is 18)

<NumoraInput decimalMaxLength={2} />

Min decimal places

Type "1" and click away. The input shows "1.00" on blur. A value your app passes is padded too. decimalMinLength above decimalMaxLength is an invalid option

<NumoraInput decimalMinLength={2} />

Separators

European format

Type a number and it displays as "1.234,56"

<NumoraInput decimalSeparator="," thousandSeparator="." />

For locale-aware separator detection, see Locale.

Built-in behavior

  • Typing , or . inserts the configured decimal separator. It is blocked if the value already has one.
  • Numora reads pasted text by its own format. When both . and , appear, the last one is the decimal, so "1,234.56" becomes 1234.56. A mark that repeats is grouping, so "12.34.56" becomes 123456.
  • A single mark. When pasted text has one . or one ,, Numora reads it as grouping only if it could be grouping: one to three digits before it, exactly three after it, and no leading zero. In a default field a pasted 12,345 becomes 12345. A pasted 1,5, 1234,567 or 0,123 becomes 1.5, 1234.567 or 0.123. The field's own decimal separator is always the decimal: a pasted 1,234 is 1234 in a default field and 1.234 in a de-DE field.
  • No decimals. With decimalMaxLength=0 Numora refuses a typed decimal separator, so typing 12.5 gives 125. A paste keeps the integer part: 12.75 becomes 12.
  • Invalid values. A negative or fractional limit, or decimalMinLength above decimalMaxLength, is an error. See invalid options.