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.

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.

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.

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.

Input Attributes

NameDescriptionTypeAccepted ValuesDefault
typetype of inputstringtext, textarea and other native input typesopen in new windowtext
modelValue / v-modelbinding valuestring / number
maxlengththe max lengthstring / number
minlengthsame as minlength in native inputnumber
show-word-limitwhether show word count, only works when type is 'text' or 'textarea'booleanfalse
placeholderplaceholder of Inputstring
clearablewhether to show clear buttonbooleanfalse
formatterspecifies the format of the value presented input.(only works when type is 'text')(value: string | number) => string
parserspecifies the value extracted from formatter input.(only works when type is 'text')(string) => string
show-passwordwhether to show toggleable password inputbooleanfalse
disabledwhether Input is disabledbooleanfalse
sizesize of Input, works when type is not 'textarea'stringlarge / default / small
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 resizabilitystringnone / both / horizontal / vertical
autofocussame as autofocus in native inputbooleanfalse
formsame as form in native inputstring
labellabel textstring
tabindexinput tabindexstring / number--
validate-eventwhether to trigger form validationboolean-true
input-stylethe style of the input element or textarea elementobject-{}
textarea-classthe custom CSS class for textarea elementstring--
prefix-classthe custom CSS class for prefix elementstring--
suffix-classthe custom CSS class for suffix elementstring--
prepend-classthe custom CSS class for prepend elementstring--
append-classthe custom CSS class for append elementstring--
roundedrounded inputboolean-false
smallsmall inputboolean-false
largelarge inputboolean-false

Input 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'

Input Events

NameDescriptionParameters
blurtriggers when Input blurs(event: FocusEvent)
focustriggers when Input focuses(event: FocusEvent)
changetriggers when the input box loses focus or the user presses Enter, only if the modelValue has changed(value: string | number)
inputtriggers when the Input value change(value: string | number)
cleartriggers when the Input is cleared by clicking the clear button

Input Methods

MethodDescriptionParameters
focusfocus the input element
blurblur the input element
selectselect the text in input element
Last Updated:
Contributors: Tam Mai