Formatting
Numora React adds thousand separators as the user types by default, or only on blur with formatOn="blur". It keeps the cursor position in both modes.
By default, grouping is 'thousand' with , as the thousand separator, in both the React component and the vanilla numora package. Pass groupingStyle="none" to turn grouping off. 'thousand' (1,234,567) is the default, so the demos below show the other two styles.
Groups of 4 from the right.
Other grouping styles
Lakh (Indian, 12,34,567)
Type a large number to see Lakh grouping
Wan (East Asian, 123,4567)
Type a large number to see Wan grouping
When to format
The separators appear on every keystroke by default, or only on blur with formatOn="blur". See Change vs blur for both modes.
When the separators move, the caret stays between the same two digits:
Naive formatter
NumoraInput
The 9 lands at the end in naive. Numora puts it after the 8.
Separator skipping
- Backspace and Delete jump over thousand separators, so you never delete one by hand.
- This applies with
formatOn="change", a thousand separator set and no text selected. In blur mode a focused field has no separators to skip. - Two handlers share the work.
keydownmoves the cursor over the separator, andbeforeinputdeletes the digit. Mobile keyboards that send no usablekeydownstill work, becausebeforeinputthen deletes the digit past the separator itself.
beforeinput then deletes the 1.