Text field

Los componentes de campo de texto se usan para recolectar información proveída por el usuario.

Uso

A simple text field with placeholder and/or label.

API

v-text-field
Nombre
append-icon
Default
undefined
Type
string

Components.TextFields.

Nombre
append-outer-icon New in — v1.1
Default
undefined
Type
string

Components.TextFields.

Nombre
autofocus
Default
false
Type
boolean

Habilita el autoenfoque

Nombre
background-color
Default
undefined
Type
string

Components.TextFields.

Nombre
box
Default
false
Type
boolean

Aplica un estilo alternativo de box al input

Nombre
browser-autocomplete
Default
undefined
Type
string

Components.TextFields.

Nombre
clear-icon
Default
'$vuetify.icons.clear'
Type
string

Components.TextFields.

Nombre
clearable
Default
false
Type
boolean

Agrega funcionalidad de limpiar el input, el ícono default es clear de Material Icons

Nombre
color
Default
'primary'
Type
string

Aplica el color especificado al control.

Nombre
counter
Default
undefined
Type
boolean | number | string

Crea un contador para la longitud del input. Si no se especifica un número, el default es 25. No aplica ninguna validación.

Nombre
dark
Default
false
Type
boolean

Aplica la variante del tema dark

Nombre
disabled
Default
false
Type
boolean

Components.TextFields.

Nombre
dont-fill-mask-blanks
Default
false
Type
boolean

Deshabilita que el caracter se muestre en automático al escribir

Nombre
error
Default
false
Type
boolean

Pone el input en un estado de error manual

Nombre
error-count
Default
1
Type
number | string

Components.TextFields.

Nombre
error-messages
Default
[]
Type
string | array

Pone el input en un estado de error y pasa los mensajes de error personalizados. Se combinará con cualquier validación que ocurra desde la prop rules. Este campo no propicia ninguna validación.

Nombre
flat
Default
false
Type
boolean

Components.TextFields.

Nombre
full-width
Default
false
Type
boolean

Indica el tipo del input como un full-width (ancho total)

Nombre
height
Default
undefined
Type
number | string

Configura la altura del componente

Nombre
hide-details
Default
false
Type
boolean

Components.TextFields.

Nombre
hint
Default
undefined
Type
string

Components.TextFields.

Nombre
label
Default
undefined
Type
string

Components.TextFields.

Nombre
light
Default
false
Type
boolean

Aplica la variante del tema light

Nombre
loading
Default
false
Type
boolean | string

Components.TextFields.

Nombre
mask
Default
undefined
Type
object | string

Aplica un caracter personalizado como máscara del input. Ve a la tabla de máscaras arriba para mayor información

Nombre
messages
Default
[]
Type
string | array

Components.TextFields.

Nombre
outline
Default
false
Type
boolean

Components.TextFields.

Nombre
persistent-hint
Default
false
Type
boolean

Components.TextFields.

Nombre
placeholder
Default
undefined
Type
string

Components.TextFields.

Nombre
prefix
Default
undefined
Type
string

Muestra un texto de prefijo

Nombre
prepend-icon
Default
undefined
Type
string

Components.TextFields.

Nombre
prepend-inner-icon New in — v1.1
Default
undefined
Type
string

Components.TextFields.

Nombre
readonly
Default
false
Type
boolean

Components.TextFields.

Nombre
return-masked-value
Default
false
Type
boolean

Regresa la cadena que fue enmascarada sin modificar

Nombre
reverse New in — v1.1
Default
false
Type
boolean

Components.TextFields.

Nombre
rules
Default
[]
Type
array

Arreglo de funciones que regresa ya sea True o un String con el mensaje de error

Nombre
single-line
Default
false
Type
boolean

La etiqueta no se mueve en los eventos focus/dirty

Nombre
solo
Default
false
Type
boolean

Components.TextFields.

Nombre
solo-inverted
Default
false
Type
boolean

Components.TextFields.

Nombre
success New in — v1.1
Default
false
Type
boolean

Components.TextFields.

Nombre
success-messages New in — v1.1
Default
[]
Type
string | array

Components.TextFields.

Nombre
suffix
Default
undefined
Type
string

Muestra un texto de sufijo

Nombre
type
Default
'text'
Type
string

Configura el tipo de input

Nombre
validate-on-blur
Default
false
Type
boolean

Retrasa la validación hasta el evento blur

Nombre
value
Default
undefined
Type
any

Controla la visibilidad

Suplementos

Mask legend
MaskDescription
Masks
#Any digit
AAny capital letter
aAny small letter
NAny capital alphanumeric character
nAny small alphanumeric character
XAny special symbol (-!$%^&*()_+|~=`{}[]:";'<>?,./\) or space
Pre-made
credit-card#### - #### - #### - ####
date-with-time##/##/#### ##:##
phone(###) ### - ####
social###-##-####
time##:##
time-with-seconds##:##:##

Ejemplos

Single line

Single line text fields do not float their label on focus or with data.

Disabled and readonly

Text fields can be disabled or readonly.

Icons

You can add icons to the text field with prepend-icon, append-icon and append-outer-icon props.

Clearable

When clearable, you can customize the clear icon with clear-icon.

Icon events

click:prepend, click:append, click:append-outer, and click:clear will be emitted when you click on the respective icon. Note that these events will not be fired if the slot is used instead.

Icon slots

Instead of using prepend / append / append-outer icons you can use slots to extend input's functionality.

Label slot

Text field label can be defined in label slot - that will allow to use HTML content

Character counter

Use a counter prop to inform a user of the character limit. The counter does not perform any validation by itself. You will need to pair it with either the internal validation system, or a 3rd party library. You can use it on regular, box or outline text fields.

Password input

A password input can be used with an appended icon and callback to control the visibility.

Validation

Vuetify includes simple validation through the rules prop. The prop accepts an array of callbacks. While validating rules, the current v-model value will be passed to the callback. This callback should return either true or a String, the error message.

Full-width text field with character counter

Full width text fields allow you to create boundless inputs. In this example, we use a v-divider to separate the fields.

Hint text

The hint property on text fields adds the provided string beneath the text field. Using persistent-hint keeps the hint visible when the text field is not focused. Hint prop is not supported in solo mode.

Prefixes & suffixes

The prefix and suffix properties allows you to prepend and append inline non-modifiable text next to the text field.

Custom validation

While the built in v-form or 3rd party plugin such as vuelidate or vee-validation can help streamline your validation process, you can choose to simply control it yourself.

Box style

Text fields can be used with an alternative box design. Append and prepend icon props are not supported in this mode.

Solo style

Text fields can be used with an alternative solo design.

Outline style

Text fields can be used with an alternative outline design.

Custom colors

You can optionally change a text field into any color in the Material design palette. Below is an example implementation of a custom form with validation.

Masks

Text fields can validate against character masks. Using either a pre-made or custom rules, you can optionally format and validate specific character sets. Note that masks work only with text fields, using them with date/number/file etc inputs may end up in unexpected behaviour or exception.

Progress bar

You can display a progress bar instead of the bottom line. You can use the default indeterminate progress having same color as the text field or designate a custom one using the progress slot

Edit this page | language on Github
Vuetify 3 is now available!The latest version of Vuetify is now available!
Learn about Vuetify 3's new features and functionality for modern Vue applications
Start exploringExplore