Form
InputNumber
A number box with steppers, clamped to a range and formatted in the locale, as a decimal, a currency or a percentage.
WAI-ARIA tested
Import
main.ts
import { InputNumber } from '@vitral/vue';Basic
Value: 3
Formats
Currency, percent, a suffix and a fixed number of digits, each read back correctly when typed.
Value: 1299.9
Value: 49.99
Value: 0.8
Value: 12.5
Sizes, variants and states
API
Read from packages/vue/src/components/InputNumber/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| min | number | — |
| max | number | — |
| step | number | What an arrow key or a spin button adds or takes away; PageUp/PageDown move ten of these. Defaults to 1. |
| mode | 'decimal' | 'currency' | 'percent' | — |
| currency | string | ISO 4217 code, such as `BRL`; required by `mode: 'currency'`. |
| locale | string | A BCP 47 tag for the number format. Defaults to the Vitral locale's `code`. |
| minFractionDigits | number | — |
| maxFractionDigits | number | — |
| useGrouping | boolean | Thousands separators. Defaults to true. |
| prefix | string | Text before the number, such as `≈ `; it is part of the display, not of the value. |
| suffix | string | Text after the number, such as ` km`. |
| showButtons | boolean | Spin buttons. |
| buttonLayout | 'stacked' | 'horizontal' | `stacked` puts up over down at the end of the field; `horizontal` puts minus before the number and plus after it. |
| allowEmpty | boolean | Whether clearing the text leaves the value empty (`null`). Defaults to true; when false, an emptied field goes back to its last value. |
| size | Size | — |
| variant | InputVariant | Defaults to the plugin's `inputVariant`. |
| invalid | boolean | — |
| disabled | boolean | — |
| readonly | boolean | — |
| fluid | boolean | — |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| input | event: InputNumberInputEvent | Every edit, as typed or spun, before the value is committed on blur or Enter. |
| focus | event: FocusEvent | — |
| blur | event: FocusEvent | — |