2021-10-22 19:32:39 +08:00
---
2021-10-25 15:21:08 +08:00
title: Input
2021-10-22 19:32:39 +08:00
lang: en-US
---
2021-09-17 00:18:50 +08:00
# Input Number
Input numerical values with a customizable range.
## Basic usage
:::demo Bind a variable to `v-model` in `<el-input-number>` element and you are set.
input-number/basic
:::
2021-10-22 23:28:03 +08:00
:::tip
When inputting invalid string to the input box, input value will emit `NaN` to the upper layer as result of error
:::
2021-09-17 00:18:50 +08:00
## Disabled
:::demo 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 `0` .
input-number/disabled
:::
## Steps
Allows you to define incremental steps.
:::demo Add `step` attribute to set the step.
input-number/steps
:::
## Step strictly
:::demo 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
:::demo 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
2021-12-12 17:54:21 +08:00
Use attribute `size` to set additional sizes with `large` or `small` .
2021-09-17 00:18:50 +08:00
:::demo
input-number/size
:::
## Controls Position
:::demo Set `controls-position` to decide the position of control buttons.
input-number/controlled
:::
## Attributes
2022-05-23 22:05:37 +08:00
| Attribute | Description | Type | Accepted Values | Default |
| ----------------------------- | ------------------------------------------------ | ---------------------- | --------------- | ----------- |
| model-value / v-model | binding value | number / undefined | — | — |
| min | the minimum allowed value | number | — | `-Infinity` |
| max | the maximum allowed value | number | — | `Infinity` |
| 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 | string | large/small | default |
2022-08-31 11:47:26 +08:00
| readonly | same as `readonly` in native input | boolean | — | false |
2022-05-23 22:05:37 +08:00
| disabled | whether the component is disabled | boolean | — | false |
| controls | whether to enable the control buttons | boolean | — | true |
| controls-position | position of the control buttons | string | right | - |
| name | same as `name` in native input | string | — | — |
| label | label text | string | — | — |
| placeholder | placeholder in input | string | - | - |
| value-on-clear ** (\> 2.2.0)** | value should be set when input box is cleared | string / number / null | min/max | - |
2022-07-02 21:01:05 +08:00
| validate-event | whether to trigger form validation | boolean | - | true |
2021-09-17 00:18:50 +08:00
## Events
2021-10-22 23:28:03 +08:00
| Event Name | Description | Parameters |
| ---------- | ------------------------------- | ------------------------------------------------------ |
| change | triggers when the value changes | (currentValue: number \| NaN, oldValue: number \| NaN) |
| blur | triggers when Input blurs | (event: Event) |
| focus | triggers when Input focuses | (event: Event) |
2021-09-17 00:18:50 +08:00
## Methods
| Method | Description | Parameters |
| ------ | -------------------------------- | ---------- |
| focus | get focus the input component | - |
| blur | remove focus the input component | — |