Number input
VNumberInput is a field for a number, with step buttons, the keyboard of a spinbutton and formatting in the locale.
Usage
vue
Between 1 and 10.
Examples
Controls
controls places the step buttons on either side, stacks them at the end, or removes them. They stay out of the Tab order: the arrow keys step from the field.
vue
Formatting
formatOptions takes the options of Intl.NumberFormat. The value is formatted outside editing and shown bare while it is typed. With style: 'percent', 0.15 is shown and typed as 15.
vue
Step
step sets how far the arrow keys and the buttons move the value, on a grid starting at min. Fractional steps do not drift.
vue
Page Up and Page Down move ten steps.
API
Props
| Prop | Type | Default |
|---|---|---|
min | number | none |
| Smallest value. A lower typed value is raised to it when committed. | ||
max | number | none |
| Largest value. A higher typed value is lowered to it when committed. | ||
step | number | 1 |
| Distance moved by the arrow keys and the buttons. Page Up and Page Down move ten steps. | ||
formatOptions | Intl.NumberFormatOptions | none |
Intl.NumberFormat options for the displayed value: currency, unit, percent or decimals. | ||
locale | string | none |
| Locale used to format and read the number. Defaults to the library locale. | ||
controls | NumberInputControls'split' | 'stacked' | 'none' | 'split' |
| Position of the step buttons. | ||
incrementLabel | string | none |
| Accessible name of the plus button. Defaults to the library dictionary. | ||
decrementLabel | string | none |
| Accessible name of the minus button. Defaults to the library dictionary. | ||
size | InputSize'sm' | 'md' | 'lg' | 'md' |
Field size. Overridden when VInputGroup sets size. | ||
compact | boolean | false |
Reduces the height without changing padding or text. Overridden when VInputGroup sets compact. | ||
label | string | none |
Visible label linked to the input. When omitted, provide aria-label or aria-labelledby. | ||
hint | string | none |
Help text below the field, linked through aria-describedby. | ||
error | string | none |
Error message shown in place of the hint. Sets aria-invalid and is announced when it appears. | ||
invalid | boolean | false |
Sets aria-invalid and the error style. | ||
disabled | boolean | false |
| Disables the field and its buttons. | ||
readonly | boolean | false |
| Prevents typing and stepping while allowing focus and copying. | ||
clearable | boolean | false |
Adds a clear button that sets the value to null. | ||
clearLabel | string | none |
| Accessible name of the clear button. Defaults to the library dictionary. | ||
loading | boolean | false |
| Shows a spinner at the end of the field. | ||
loadingText | string | none |
| Accessible spinner text. Defaults to the library dictionary. | ||
v-model | number | null | null |
Field value, a number, or null when empty. Typed text is committed on blur and on Enter. | ||
Events
| Event | Type |
|---|---|
clear | [] |
Emitted after the clear button sets the value to null. | |