com.vaadin.flow.component.textfield.

Class TextArea

All Implemented Interfaces:

AttachNotifier, BlurNotifier<TextArea>, CompositionNotifier, DetachNotifier, Focusable<TextArea>, FocusNotifier<TextArea>, HasAriaLabel, HasElement, HasEnabled, HasHelper, HasLabel, HasPlaceholder, HasSize, HasStyle, HasTheme, HasValidation, HasValue<AbstractField.ComponentValueChangeEvent<TextArea,String>,String>, HasValueAndElement<AbstractField.ComponentValueChangeEvent<TextArea,String>,String>, InputNotifier, KeyNotifier, HasAllowedCharPattern, HasClearButton, HasClientValidation, HasPrefix, HasSuffix, HasThemeVariant<TextAreaVariant>, HasTooltip, HasValidationProperties, InputField<AbstractField.ComponentValueChangeEvent<TextArea,String>,String>, HasAutocapitalize, HasAutocomplete, HasAutocorrect, HasPrefixAndSuffix, HasValidator<String>, HasValueChangeMode, Serializable

@Tag("vaadin-text-area") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.7.1") @NpmPackage(value="@vaadin/text-area",version="24.7.1") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/text-area/src/vaadin-text-area.js") public class TextArea extends TextFieldBase<TextArea,String> implements HasAllowedCharPattern, HasThemeVariant<TextAreaVariant>

Text Area is an input field component for multi-line text input. Text Area is typically used for descriptions, comments, and other longer free-form content.

Validation

Text Area comes with a built-in validation mechanism based on constraints. Validation is triggered whenever the user applies an input change, for example by pressing Enter or blurring the field. Programmatic value changes trigger validation as well. In eager and lazy value change modes, validation is also triggered on every character press with a delay according to the selected mode.

Validation verifies that the value satisfies the specified constraints. If any of the constraints are violated, the component is marked as invalid and an error message is displayed below the input.

The following constraints are supported:

Error messages for constraints can be configured with the TextArea.TextAreaI18n object, using the respective properties. If you want to provide a single catch-all error message, you can also use the setErrorMessage(String) method. Note that such an error message will take priority over i18n error messages if both are set.

In addition to validation, constraints may also limit user input. For example, the browser will prevent the user from entering more text than specified by the max length constraint.

For more advanced validation that requires custom rules, you can use Binder. By default, before running custom validators, Binder will also check the component constraints and display error messages from the TextArea.TextAreaI18n object. The exception is the required constraint, for which Binder provides its own API, see asRequired().

However, if Binder doesn't fit your needs and you want to implement fully custom validation logic, you can disable the constraint validation by setting setManualValidation(boolean) to true. This will allow you to control the invalid state and the error message manually using HasValidationProperties.setInvalid(boolean) and setErrorMessage(String) API.

Author:

Vaadin Ltd.

See Also: