Input ​

Ingresa datos usando el ratón o teclado.

Uso básico ​

Deshabilitar ​

Deshabilite el Input con el atributo disabled.

Limpiable ​

Marque que el input puede ser limpiable con el atributo clearable. After version 2.13.4, the clearable feature is also available for textarea type of Input.

Custom Clear Icon 2.11.0 ​

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

Formato ​

Muestre el valor, según la situación, con formatter, y normalmente se usa parser al mismo tiempo.

Contraseña ​

Puede hacer un input de contraseña conmutable con el atributo show-password. Since 2.13.6, the password-icon slot is supported to override the default icon.

Input con icono ​

Añada un icono para indicar el tipo de Input.

Para añadir iconos en el Input, puede utilizar los atributos prefix-icon y suffix-icon. Además, los slots con nombre prefix y suffix también funcionan.

Using attributes
Using slots

Textarea ​

Redimensionable para introducir múltiples líneas de información de texto. Agregue el atributo type="textarea" para cambiar el input al tipo nativo textarea.

Controle la altura ajustando la propiedad rows.

Textarea de tamaño automático ​

El ajuste de la propiedad autosize en el tipo de Input textarea hace que la altura se ajuste automáticamente en función del contenido. Se pueden proporcionar opciones en un objeto para autosize y especificar el número mínimo y máximo de líneas que el textarea puede ajustar automáticamente.

Mezclando elementos con input ​

Añada un elemento antes o después del input, generalmente será una etiqueta o un botón.

Utilice el slot para seleccionar si el elemento se colocara antes (prepend) o después (append) del Input.

Http://
.com
Select
Select

Tamaños ​

Añada el atributo size para cambiar el tamaño del Input. Además del tamaño predeterminado, hay otras dos opciones: large, small.

Limitar el tamaño ​

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

Count graphemes 2.13.7 ​

Set count-graphemes to calculate text length. If it's set, native maxlength and minlength won't be used.

2 / 10
2 / 20

TIP

Browser Support & Fallback Strategy

When using the count-graphemes prop, the component employs the following approach:

  • Primary: Uses Intl.Segmenter API (Chrome 87+, Firefox 125+, Safari 14.1+) for proper grapheme cluster handling. This correctly handles complex emoji, combining marks, and Zero Width Joiner sequences.

  • Fallback: Older browsers fall back to Array.from() for code-point based iteration. Note that this may split multi-codepoint grapheme sequences (e.g., emoji with skin tone modifiers).

When implementing your own count-graphemes function, consider using Intl.Segmenter if you need robust support for complex unicode characters.

API ​

Atributos ​

NombreDescripciónTipoPor defecto
typetype of input, see more in MDNstringtext
model-value / v-modelvalor enlazadostring / number—
model-modifiers 2.11.5v-model modifiers, reference Vue modifiersobject—
maxlengthsame as maxlength in native inputstring / number—
minlengthigual que minlength en el input nativostring / number—
show-word-limitsi se muestra el contador de palabras, solamente funciona cuando type es 'text' o 'textarea'booleanfalse
word-limit-position 2.11.5word count position, valid when show-word-limit is trueenum"inside"
placeholderplaceholder del Inputstring—
clearablesi mostrar el botón limpiar, solo funciona cuando type no es 'textarea'booleanfalse
clear-icon 2.11.0personaliza el componente de icono de limpiezastring / objectCircleClose
formatterespecifica el formato del valor presentado en el input.(solo funciona cuando type es 'text')Function—
parserespecifica el valor extraído del input formateado.(solo funciona cuando type es 'text')Function—
show-passwordsi debe mostrar la posibilidad de conmutación en el input de tipo passwordbooleanfalse
disabledsi esta deshabilitadobooleanfalse
sizetamaño del input, esto funciona cuando type no es 'textarea'enum—
prefix-iconcomponente de icono prefijostring / Component—
suffix-iconcomponente de icono sufijostring / Component—
rowsnúmero de filas, solo funciona cuando type es 'textarea'number2
autosizesi textarea tiene una altura adaptativa, solo funciona cuando type es 'textarea'. Puede aceptar un objeto, por ejemplo, { minRows: 2, maxRows: 6 }boolean / objectfalse
autocompleteigual que autocomplete en el input nativostringoff
namecomo name en el input nativostring—
readonlyigual que readonly en el input nativobooleanfalse
maxigual que max en el input nativo——
minigual que min en el input nativo——
stepigual que step en el input nativo——
resizecontrolar la resizabilidadenum—
autofocusigual que autofocus en el input nativobooleanfalse
formigual que form en el input nativostring—
aria-label a11y 2.7.2igual que aria-label en el input nativostring—
tabindexorden de tabulación para el Inputstring / number—
validate-eventsi se debe lanzar la validación de formulariobooleantrue
input-styleel estilo del elemento input o elemento textareastring / object{}
label a11y deprecatedsame as aria-label in native inputstring—
inputmode 2.10.3same as inputmode in native inputstring—
count-graphemes 2.13.7custom function to count graphemes; when set, native maxlength/minlength constraints are bypassed. Component uses Intl.Segmenter (Chrome 87+, Firefox 125+, Safari 14.1+) for proper grapheme clustering; older browsers fall back to Array.from() for code-point iterationFunction—

Eventos ​

NombreDescripciónTipo
blurse dispara cuando el input pierde el focoFunction
focusse lanza cuando el input se enfocaFunction
changese dispara cuando el input pierde el foco o el usuario presiona Enter, solo si el modelValue ha cambiadoFunction
inputse dispara cuando el valor del input cambiaFunction
clearse dispara cuando el input se borra haciendo clic en el botón de borrarFunction
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 ​

NombreDescripción
prefixcontenido como prefijo del input, solo funciona cuando type no es 'textarea'
suffixcontenido como sufijo del input, solo funciona cuando type no es 'textarea'
prependcontenido a añadir antes del input, solo funciona cuando type no es 'textarea'
appendcontenido para añadir después del input solo funciona cuando type no es 'textarea'
password-icon 2.13.6content as Input password icon, only works when show-password is true. The scope variable is { visible: boolean }

Expuesto ​

NombreDescriciónTipo
blurquita el foco en el inputFunction
clearborra contenido del inputFunction
focuscoloca el foco en el inputFunction
inputElemento HTML inputobject
refElemento HTML, input o textareaobject
resizeTextarearedimensiona textareaFunction
selectselecciona el texto del inputFunction
textareaElemento HTML textareaobject
textareaStyleestilo de textareaobject
isComposing 2.8.0is input composingobject
passwordVisible 2.13.7whether the password is visibleobject

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" />

Fuente ​

Componentes • Style • Documentación

Contribuidores ​