Input ​

Input data using mouse or keyboard.

Basic usage ​

Disabled ​

Disable the Input with the disabled attribute.

Clearable ​

Make the Input clearable with the clearable attribute.

Custom Clear Icon 2.11.0 ​

You can customize the clear icon by setting the clear-icon attribute.

Formatter ​

Display value within it's situation with formatter, and we usually use parser at the same time.

Password box ​

Make a toggle-able password Input with the show-password attribute.

Input with icon ​

Add an icon to indicate input type.

To add icons in Input, you can simply use prefix-icon and suffix-icon attributes. Also, the prefix and suffix named slots works as well.

Using attributes
Using slots

Textarea ​

Resizable for entering multiple lines of text information. Add attribute type="textarea" to change input into native textarea.

Control the height by setting the rows prop.

Autosize Textarea ​

Setting the autosize prop for a textarea type of Input makes the height to automatically adjust based on the content. An options object can be provided to autosize to specify the minimum and maximum number of lines the textarea can automatically adjust.

Mixed input ​

Prepend or append an element, generally a label or a button.

Use slot to distribute elements that prepend or append to Input.

Http://
.com
Select
Select

Sizes ​

Add size attribute to change the size of Input. In addition to the default size, there are two other options: large, small.

Limit length ​

maxlength and minlength attributes of input, they declare a limit on the number of characters a user can input. The "number of characters" is measured using JavaScript string length.Setting the maxlength prop for a text or textarea type of Input can limit the length of input value, allows you to show word count by setting show-word-limit to true at the same time. In 2.11.5, You can set word-limit-position to outside to display the word count outside the input.

0 / 10
0 / 10
0 / 30
0 / 30

API ​

Attributes ​

NameDescriptionTypeDefault
typetype of inputstring native input typestext
model-value / v-modelbinding valuestring / number—
model-modifiers 2.11.5v-model modifiers, reference Vue modifiersobject—
maxlengthsame as maxlength in native inputstring / number—
minlengthsame as minlength in native inputstring / number—
show-word-limitwhether show word count, only works when type is 'text' or 'textarea'booleanfalse
word-limit-position 2.11.5word count position, valid when show-word-limit is trueenum"inside"
placeholderplaceholder of Inputstring—
clearablewhether to show clear button, only works when type is not 'textarea'booleanfalse
clear-icon 2.11.0custom clear icon componentstring / objectCircleClose
formatterspecifies the format of the value presented input.(only works when type is 'text')Function—
parserspecifies the value extracted from formatter input.(only works when type is 'text')Function—
show-passwordwhether to show toggleable password inputbooleanfalse
disabledwhether Input is disabledbooleanfalse
sizesize of Input, works when type is not 'textarea'enum—
prefix-iconprefix icon componentstring / Component—
suffix-iconsuffix icon componentstring / Component—
rowsnumber of rows of textarea, only works when type is 'textarea'number2
autosizewhether textarea has an adaptive height, only works when type is 'textarea'. Can accept an object, e.g. { minRows: 2, maxRows: 6 }boolean / objectfalse
autocompletesame as autocomplete in native inputstringoff
namesame as name in native inputstring—
readonlysame as readonly in native inputbooleanfalse
maxsame as max in native input——
minsame as min in native input——
stepsame as step in native input——
resizecontrol the resizabilityenum—
autofocussame as autofocus in native inputbooleanfalse
formsame as form in native inputstring—
aria-label a11y 2.7.2same as aria-label in native inputstring—
tabindexinput tabindexstring / number—
validate-eventwhether to trigger form validationbooleantrue
input-stylethe style of the input element or textarea elementstring / object{}
label a11y deprecatedsame as aria-label in native inputstring—
inputmode 2.10.3same as inputmode in native inputstring—

Events ​

NameDescriptionType
blurtriggers when Input blursFunction
focustriggers when Input focusesFunction
changetriggers when the input box loses focus or the user presses Enter, only if the modelValue has changedFunction
inputtriggers when the Input value changeFunction
cleartriggers when the Input is cleared by clicking the clear buttonFunction
keydowntriggers when a key is pressed downFunction
mouseleavetriggers when the mouse leaves the Input elementFunction
mouseentertriggers when the mouse enters the Input elementFunction
compositionstarttriggers when the composition startsFunction
compositionupdatetriggers when the composition is updatedFunction
compositionendtriggers when the composition endsFunction

Slots ​

NameDescription
prefixcontent as Input prefix, only works when type is not 'textarea'
suffixcontent as Input suffix, only works when type is not 'textarea'
prependcontent to prepend before Input, only works when type is not 'textarea'
appendcontent to append after Input, only works when type is not 'textarea'

Exposes ​

NameDescriptionType
blurblur the input elementFunction
clearclear input valueFunction
focusfocus the input elementFunction
inputHTML input elementobject
refHTML element, input or textareaobject
resizeTextarearesize textareaFunction
selectselect the text in input elementFunction
textareaHTML textarea elementobject
textareaStylestyle of textareaobject
isComposing 2.8.0is input composingobject

FAQ ​

Why is the width of the ElInput component expanded by clearable? ​

Typical issue: #7287

PS: Since the ElInput component does not have a default width, when the clearable icon is displayed, the width of the component will be expanded, which can be solved by setting width.

vue
<el-input v-model="input" clearable style="width: 200px" />

Source ​

Component • Style • Docs

Contributors ​