Number input
VNumberInput is a field for a number, with step buttons, the keyboard of a spinbutton and formatting in the locale.
Usage
vue
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
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. | ||
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. | ||
required | boolean | false |
Adds an asterisk after the label and passes required to the field. | ||
hideLabel | boolean | false |
| Hides the label visually while keeping it as the accessible name. | ||
labelPosition | FieldLabelPosition'top' | 'start' | 'top' |
| Places the label above the field or beside it. | ||
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. | |