Locale
The locale prop detects thousand and decimal separators, and the digit-grouping style, via Intl.NumberFormat. An explicit groupingStyle overrides the detected one.
de-CH- Thousand separator
- apostrophe
- Decimal separator
- full stop
- Grouping
- 3-3-3
Specific locale tag
Pass a BCP 47 locale tag to pin separators to one locale. Use this whenever the field is rendered on the server. There, locale={true} resolves to the server's locale, which may not match the browser, and logs a warning in development.
locale="de-DE"
German separators: 1234567.89 displays as 1.234.567,89
Browser locale (auto-detect)
Pass locale={true} to detect both separators from the browser's current locale. Explicit thousandSeparator or decimalSeparator values win over locale-detected ones.
locale={true}
Both separators come from your browser's locale
Grouping style detection
Indic locales group as 3-2-2 (lakh/crore) rather than 3-3-3. When groupingStyle is left unset, it is derived from the locale, so hi-IN and en-IN get 'lakh'.
locale="en-IN"
Grouping derived from the locale: 12345678 displays as 1,23,45,678
locale="en-IN" groupingStyle="thousand"
An explicit groupingStyle wins over the locale: 12345678 displays as 12,345,678
Only 'thousand' and 'lakh' can be detected. 'wan' (4-4-4) cannot be derived from Intl.NumberFormat, because zh-CN and ja-JP both report Western 3-3-3 grouping. Pass 'wan' explicitly.
Where the separators come from
Numora does not read the browser's locale unless you ask it to. A separator you pass wins, locale fills in the ones you did not set, and the defaults fill in the rest.
| You pass | Thousand | Decimal |
|---|---|---|
| Nothing | , | . |
locale="de-DE" | . | , |
locale="de-DE" thousandSeparator=" " | space | , |
thousandSeparator="." | . | , (switched) |
decimalSeparator="," | . (switched) | , |
The last two rows show that a separator you pass never clashes with one you did not. If it is the character the defaults or the locale would use for the other separator, the other one switches.
A separator must follow three rules:
- It is exactly one character.
- It is not a digit or one of
- + e E k K m M b B t T, which Numora reads as a sign, an exponent or a compact-notation suffix. - The thousand and decimal separators are different characters.
Numora throws on an invalid separator in development, including when you pass the same character for both. In a production build it logs the error and keeps the last valid options, or the defaults if the first render was invalid.
getSeparatorsFromLocale
getSeparatorsFromLocale returns the separators and grouping style for a tag, so you can read them or pass them in yourself.
To set the decimal separator without a locale, see Decimals.
What the field displays
The field shows the locale's separators with ASCII digits and an ASCII minus. In ar-EG it shows 1٬234٫5, not the Arabic-Indic ١٬٢٣٤٫٥ that Intl.NumberFormat prints. In sv-SE it shows the hyphen-minus (U+002D), not the minus sign (U+2212). Typed and pasted native digits and minus signs are still accepted and folded to ASCII. With thousand grouping, four-digit numbers are grouped too (1.234 in es-ES), even where Intl leaves them ungrouped.
Changing the locale later
Change the locale prop on a mounted field. The raw value is kept and the display is rewritten with the new separators. An invalid tag throws in development and is logged in production. locale={false} turns locale handling off and uses the thousandSeparator and decimalSeparator props.
Value format under a locale
The separators only change what the field shows. value and defaultValue take the canonical raw value in every locale: ASCII digits, . as the decimal mark, no grouping. Under locale="de-DE", value="1234.5" displays "1.234,5", and e.target.value is "1234.5". See Value types for the full value contract.