Skip to content

Change vs blur

The formatOn prop decides when the thousand separators appear. It has two modes: "change" (the default) and "blur". The raw value you get from onValueChange is the same in both.

Change

The separators update on every keystroke, and the caret stays where the user left it.

<NumoraInput formatOn="change" decimalMaxLength={2} />

Blur

The field shows plain digits while it has focus. Numora removes the separators when the field takes focus and puts them back when it loses focus.

Blur the field to format.
<NumoraInput formatOn="blur" decimalMaxLength={2} />

Removing and restoring the separators does not change the raw value, so onChange and onValueChange stay silent on focus and blur. onFormattedValueChange reports the new text. Numora groups a value you pass while the field is unfocused.

onChange and onValueChange fire on blur only when blur also changes the raw value. This holds in both modes.

Blur changes the raw value in these cases, and no others:

  • A trailing decimal separator is dropped: 1. becomes 1.
  • decimalMinLength pads the decimals: with 2, 1.5 becomes 1.50.
  • A negative zero loses its sign: -0 becomes 0 and -0.00 becomes 0.00.
  • A value with no digit is cleared: -, . and -. become an empty string.

Which one to use

Keep the default for amounts the user reads while typing, such as a price or a token amount. Use "blur" when users edit digits in the middle of a long number. No separator moves under the caret while they type.

The demos on this page animate the digits with Torph. See the Torph integration to build them, and Formatting for the grouping styles.