textArea
textArea is an input field for entering multiple lines of text.
XML Element |
|
|---|---|
Java Class |
|
Basics
Use textArea when the expected input could span multiple lines such as commentary or descriptions.
<textArea id="textArea" value="Great job. This is excellent!" label="Comment"
valueChangeMode="EAGER" maxLength="140" helperText="29/140"/>
<textArea id="textArea2" value="Everything you do works great!" label="Additional comment"/>
Unless set to a fixed height, textArea adjusts its height automatically based on its content. The default and minimum height is two rows of text.
Data-aware textArea
Use the dataContainer and property attributes to bind textArea to a String entity attribute. The data container provides the entity instance, and property identifies the attribute to edit.
The following example produces a data-aware textArea:
<data>
<instance id="orderDc"
class="io.jmix.uisamples.entity.Order"
fetchPlan="_local"/>
</data>
<layout>
<textArea id="textArea" label="Order description"
dataContainer="orderDc" property="description"/>
<hbox>
<span text="Value in the container:"/>
<span id="spanValue"/>
</hbox>
</layout>
@ViewComponent
protected InstanceContainer<Order> orderDc;
@ViewComponent
protected Span spanValue;
@Autowired
protected Metadata metadata;
@Subscribe
protected void onInit(InitEvent event) {
Order order = metadata.create(Order.class);
order.setDescription("Deliver as quickly as possible.");
orderDc.setItem(order);
}
@Subscribe("textArea")
protected void onTextAreaValueChange(ComponentValueChangeEvent<JmixTextArea, String> changeEvent) {
spanValue.setText(orderDc.getItem().getDescription());
}
Ensure that the entity attribute you are binding to is of String type. Unlike textField, textArea is specifically designed to work with textual data.
Resizable Text Area
Apply a resize class to let users resize a text area horizontally, vertically, or in both directions. The CSS sets the corresponding resize value and enables overflow handling.
<textArea id="textArea" label="Standard TextArea"/>
<textArea id="resizableBothTextArea" label="Resizeable TextArea"
classNames="resizable-both"
themeNames="helper-above-field"
helperText="Both direction"/>
<textArea id="resizableVerticalTextArea" label="Resizeable TextArea"
classNames="resizable-vertical"
themeNames="helper-above-field"
helperText="Vertical direction"/>
<textArea id="resizableHorizontalTextArea" label="Resizeable TextArea"
classNames="resizable-horizontal"
themeNames="helper-above-field"
helperText="Horizontal direction"/>
.resizable-both {
resize: both;
overflow: auto;
padding-bottom: unset;
}
.resizable-vertical {
resize: vertical;
overflow: auto;
padding-bottom: unset;
}
.resizable-horizontal {
resize: horizontal;
overflow: auto;
padding-bottom: unset;
}
Theme Variants
Use the themeNames attribute to apply one or more theme variants.
| Variant | Description | Supported By |
|---|---|---|
|
Makes the component smaller. |
Aura, Lumo |
|
Aligns the field value to the left side. |
Aura, Lumo |
|
Centers the field value. |
Aura, Lumo |
|
Aligns the field value to the right side. |
Aura, Lumo |
|
Renders the helper text above the field, below the label. |
Aura, Lumo |
Attributes
The following attributes are specific to textArea:
| Name | Description | Default |
|---|---|---|
Sets the component identifier. |
— |
|
Controls whether the user can interact with the component. |
|
|
Sets helper text displayed near the component. |
— |
|
Sets the component label. |
— |
|
Sets placeholder text shown when the field is empty. |
— |
|
Controls whether the value can be changed by the user. |
|
|
Sets the component value. |
— |
|
Controls whether the component is displayed. |
|
|
Specifies the data container that provides the bound entity. |
— |
|
Specifies the entity attribute bound to the component. |
— |
|
Sets the component height. |
— |
|
Sets the maximum component height. |
— |
|
Sets the maximum component width. |
— |
|
Sets the minimum component height. |
— |
|
Sets the minimum component width. |
— |
|
Sets the component width. |
— |
|
Overrides the component’s alignment inside its parent layout. |
|
|
Sets the number of columns occupied in a form layout. |
|
|
Adds CSS class names to the component. |
— |
|
Controls whether the field displays a clear button. |
|
|
Defines inline CSS properties. |
— |
|
Sets the maximum number of rows. |
— |
|
Sets the minimum number of rows. |
2 |
|
Sets the message displayed when the component is invalid. |
— |
|
Sets the maximum accepted input length. |
— |
|
Sets the minimum accepted input length. |
— |
|
Sets the regular expression used to validate input. |
— |
|
Controls whether the component requires a value. |
|
|
Restricts input to characters that match the specified regular expression. |
— |
|
Defines an accessible label when no suitable visible label exists. |
— |
|
Identifies another component that provides the accessible label. |
— |
|
Controls automatic capitalization for user input. |
— |
|
Controls browser autocomplete for the field. |
— |
|
Controls automatic correction for user input. |
— |
|
Moves keyboard focus to the component when the view opens. |
|
|
Set to |
— |
|
Defines a keyboard shortcut that focuses the component. |
— |
|
Controls the component’s position in the keyboard focus order. |
|
|
If |
— |
The following shared attributes are supported by textArea:
Handlers
The following handlers are specific to textArea:
| Name | Description |
|---|---|
Fired when the component is attached to the UI. |
|
Fired when the component loses focus. |
|
Fired after client-side validation changes the component’s validity. |
|
Fired when the component value changes. |
|
Fired when a text composition session ends. |
|
Fired when a text composition session starts. |
|
Fired when text in an active composition session changes. |
|
Fired when the component is detached from the UI. |
|
Fired when the component receives focus. |
|
Fired when the user changes the input value. |
|
Fired when the user presses a key while the component has focus. |
|
Fired when a character-producing key is pressed. |
|
Handles changes to the component’s validation status. |
|
Adds a validator instance to the component. |