---
title: Input Number 数字输入框
---

# Input Number 数字输入框

Input numerical values with a customizable range.

## Basic usage

:::example Bind a variable to `v-model` in `<el-input-number>` element and you are set.

input-number/basic

:::

:::tip

When inputting invalid string to the input box, input value will emit `NaN` to the upper layer as result of error

:::

## Disabled

:::example The `disabled` attribute accepts a `boolean`, and if the value is `true`, the component is disabled. If you just need to control the value within a range, you can add `min` attribute to set the minimum value and `max` to set the maximum value. By default, the minimum value is `Number.MIN_SAFE_INTEGER`.

input-number/disabled

:::

## Steps

Allows you to define incremental steps.

:::example Add `step` attribute to set the step.

input-number/steps

:::

## Step strictly

:::example The `step-strictly` attribute accepts a `boolean`. if this attribute is `true`, input value can only be multiple of step.

input-number/step-strictly

:::

## Precision

:::example Add `precision` attribute to set the precision of input value.

input-number/precision

:::

:::tip

The value of `precision` must be a non negative integer and should not be less than the decimal places of `step`.

:::

## Size

Use attribute `size` to set additional sizes with `large` or `small`.

:::example

input-number/size

:::

## Controls Position

:::example Set `controls-position` to decide the position of control buttons.

input-number/controlled

:::

## Custom Icon ^(2.6.3)

:::example Use `decrease-icon` and `increase-icon` to set custom icons.

input-number/custom

:::

## With prefix and suffix ^(2.8.4)

:::example Use the prefix and suffix named slots.

input-number/with-prefix-suffix

:::

:::tip

For precision purposes, the input number is limited from [Number.MIN_SAFE_INTEGER](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER) to [Number.MAX_SAFE_INTEGER](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER).

:::

## Formatter ^(2.14.0)

Display the value with `formatter`, and typically use `parser` alongside it.

When `formatter` is set, the inner input `type` changes to `text`, which allows non-numeric characters to be entered. Internally, the component processes input with `Number.parseFloat`: when parsing succeeds, the parsed number is written to `model-value`; when parsing returns `NaN`, `model-value` is set to `null`.

:::example

input-number/formatter

:::

## API

### Attributes

| Name                          | Description                                              | Type                                          | Default                 |
| ----------------------------- | -------------------------------------------------------- | --------------------------------------------- | ----------------------- |
| model-value / v-model         | binding value                                            | ^[number] / ^[null]                           | —                       |
| min                           | the minimum allowed value                                | ^[number]                                     | Number.MIN_SAFE_INTEGER |
| max                           | the maximum allowed value                                | ^[number]                                     | Number.MAX_SAFE_INTEGER |
| step                          | incremental step                                         | ^[number]                                     | 1                       |
| step-strictly                 | whether input value can only be multiple of step         | ^[boolean]                                    | false                   |
| precision                     | precision of input value                                 | ^[number]                                     | —                       |
| size                          | size of the component                                    | ^[enum]`'large' \| 'default' \| 'small'`      | default                 |
| readonly ^(2.2.16)            | same as `readonly` in native input                       | ^[boolean]                                    | false                   |
| disabled                      | whether the component is disabled                        | ^[boolean]                                    | false                   |
| controls                      | whether to enable the control buttons                    | ^[boolean]                                    | true                    |
| controls-position             | position of the control buttons                          | ^[enum]`'' \| 'right'`                        | —                       |
| name                          | same as `name` in native input                           | ^[string]                                     | —                       |
| aria-label ^(a11y) ^(2.7.2)   | same as `aria-label` in native input                     | ^[string]                                     | —                       |
| placeholder                   | same as `placeholder` in native input                    | ^[string]                                     | —                       |
| id                            | same as `id` in native input                             | ^[string]                                     | —                       |
| value-on-clear ^(2.2.0)       | value should be set when input box is cleared            | ^[number] / ^[null] / ^[enum]`'min' \| 'max'` | —                       |
| validate-event                | whether to trigger form validation                       | ^[boolean]                                    | true                    |
| label ^(a11y) ^(deprecated)   | same as `aria-label` in native input                     | ^[string]                                     | —                       |
| inputmode ^(2.10.3)           | same as `inputmode` in native input                      | ^[string]                                     | —                       |
| align ^(2.10.5)               | alignment for the inner input text                       | ^[enum]`'left' \| 'center' \| 'right'`        | 'center'                |
| disabled-scientific ^(2.10.5) | disables input of scientific notation (e.g. 'e')         | ^[boolean]                                    | false                   |
| tabindex ^(2.14.0)            | same as `tabindex` in native input                       | ^[string] / ^[number]                         | 0                       |
| formatter ^(2.14.0)           | specifies the format of the value presented in the input | ^[Function]`(value: string) => string`        | —                       |
| parser ^(2.14.0)              | specifies the value extracted from the formatted input   | ^[Function]`(value: string) => string`        | —                       |

### Slots

| Name                   | Description                           |
| ---------------------- | ------------------------------------- |
| decrease-icon ^(2.6.3) | custom input box button decrease icon |
| increase-icon ^(2.6.3) | custom input box button increase icon |
| prefix ^(2.8.4)        | content as Input prefix               |
| suffix ^(2.8.4)        | content as Input suffix               |

### Events

| Name   | Description                     | Type                                                                                    |
| ------ | ------------------------------- | --------------------------------------------------------------------------------------- |
| change | triggers when the value changes | ^[Function]`(currentValue: number \| undefined, oldValue: number \| undefined) => void` |
| blur   | triggers when Input blurs       | ^[Function]`(event: FocusEvent) => void`                                                |
| focus  | triggers when Input focuses     | ^[Function]`(event: FocusEvent) => void`                                                |

### Exposes

| Name  | Description                      | Type                    |
| ----- | -------------------------------- | ----------------------- |
| focus | get focus the input component    | ^[Function]`() => void` |
| blur  | remove focus the input component | ^[Function]`() => void` |
