Number field
A number input formatted for the locale, with a currency and a step.
Describe the format in formatOptions, as for Intl.NumberFormat. A typed number reaches the model when the user leaves the field or presses Enter.
Installation
import { NuiNumberField } from '@numior/kit';Usage
Change the bounds, the step and the buttons of the field.
Examples
Limit the range
Set min, max and step.
From 0 to 50% in steps of 5
A number outside the range turns into the nearest bound when the user leaves the field. A value that was never edited in the field stays in the model as it was.
Show the number in another format
Pass locale to the field.
A field without locale follows the app language.
Accessibility
The field has the spinbutton role, so a screen reader announces the value with the minimum and the maximum. The plus and minus buttons are hidden from it and never take focus: the arrow keys do the same.
On iOS the decimal keypad has no minus sign, so pass inputmode="text" for negative numbers.