Documentation versions (currently viewingVaadin 23)

Text Field

Text Field allows the user to input and edit text. Prefix and suffix components, such as icons, are also supported.

Open in a
new tab
<vaadin-text-field label="Street Address" value="Ruukinkatu 2" clear-button-visible>
  <vaadin-icon slot="prefix" icon="vaadin:map-marker"></vaadin-icon>

Common Input Field Features

Text Field includes all shared input field features.

The features described here for Text Field are generally also available for other single-line text input components.


A placeholder is a short description of the expected input value. It is only shown when the text field is empty.

Open in a
new tab
<vaadin-text-field placeholder="Search">
  <vaadin-icon slot="prefix" icon="vaadin:search"></vaadin-icon>

Note that placeholders are not universal substitutes for labels, as they are only visible while the field is empty. Helpers are a better way to provide information that the user may need when filling in the field. Unless marked as required, fields with placeholders also risk being inadvertently skipped when filling in a form.

Search fields are a good example of where placeholders can be used without a label, if they are prefixed or suffixed with a search icon or next to a search button.

Fields with placeholders, but without labels, should also provide an invisible label using the aria-label attribute to ensure that screen readers can access it.

Clear Button

The optional clear button clears the field’s current value. It is hidden while the field is empty. Clear buttons are useful for search and filter fields, where it is common for the user to want to clear the field value. However, in data entry forms, they are typically unnecessary.

Open in a
new tab
<vaadin-text-field value="Value" clear-button-visible></vaadin-text-field>

Text Alignment

Three different text alignments are supported: left (default), center, and right.

Right-aligned values are recommended for numerical values when presented in vertical groups, as this makes it easier to interpret and compare values.

Open in a
new tab
<vaadin-text-field value="value" theme="align-right"></vaadin-text-field>
Numeric fields
Number Field is a better choice for certain numeric fields.

Prefix and Suffix

Open in a
new tab
<vaadin-text-field label="Username" placeholder="username" value="maverick">
  <vaadin-icon slot="prefix" icon="vaadin:user"></vaadin-icon>

  label="Email Address"
  <div slot="suffix"></div>

Prefixes and suffixes can be used to display currency, units, icons, etc. Text or icons are recommended, but other elements can be used as well, if they fit into the field.

Prefixes and suffixes should not be used as a replacement for labels, except in cases like search fields, preferably combined with a placeholder.

Prefix and suffix are ignored by screen readers
Any information relevant for assistive technologies needs to be provided as a label and possibly helper text.

Min and Max Input Length

These properties affect the smallest and largest number of characters a field accepts, by limiting text entry to the max length, and triggering a validation error if a shorter value than the min length is entered. They can be used to enforce specific value formats, or to cap the value to the longest length supported by the underlying database schema.

Open in a
new tab
  label="Zip code"
  style="width: 6em"

  helper-text="Max 16 characters"

In cases where the length requirements may not be clear to the user, it is recommended to provide this information, for example by using a helper.


Defines the pattern (using regular expressions) that the input must adhere to, to prevent the user from entering an invalid value.

Open in a
new tab
  label="Phone number"
  helper-text="Format: +(123)456-7890"

This example allows the input of only numbers, parentheses, dashes, and the plus sign. In cases where the format requirements may not be clear to the user, it is recommended to provide this information, for example by using a helper.

Small Variant

The small theme variant can be used to make individual fields more compact.

Open in a
new tab
<vaadin-text-field theme="small" label="Small size" value="Value"></vaadin-text-field>
Avoid overuse
Size variants should be used sparingly. See Size and Space for details on how to change the default text field size.


When a field is set to autoselect, its contents are selected when the field is focused. Use autoselect when the user might to want to replace the entire value rather than tweak it.

AutoselectFocused withResult


Pointing device or keyboard navigation

Contents selected


Pointing device

Cursor placed where clicked


Keyboard navigation

Cursor at the end of the input value


Keyboard navigation

Contents selected[1]

A variety of components are available for different types of input:

ComponentUsage Recommendations

Text Area

Free-form multi-line text input, for text longer than can typically fit on a single line.

Email Field

For email addresses.

Number Field

Allows only numeric input.

Password Field

For securely entering passwords.

Combo Box

For selecting from a predefined set of options. Allows filtering and entering custom values.

Date Picker

Input field for entering or selecting a specific date.

Time Picker

Input field for entering or selecting a specific time.


1. Consequent keyboard navigation results in the contents being selected until the selection is changed, by either arrow navigation or mouse click.