TextArea
The TextArea component can be used as a multi-line plain-text editing control
to enter free-form text, such as a comment on a form. The component uses a
fallback FormFieldMessages context if it wasn't wrapped in a FormField.
Import
import { TextArea } from '@dynatrace/strato-components/forms';
Demo
This is the simplest version of the TextArea which is uncontrolled and
therefore handles its state internally. You can also set a specific initial
value using the defaultValue prop.
Control state
The TextArea can also be controlled, meaning that you can handle the state. To
do so, you need to use the onChange prop to provide a handler that is called
when the internal state of the TextArea changes. You also need to assign the
value from the state to the TextArea by setting the value prop.
Disable resizing
The TextArea component is resizable by default. However, in case you need to
disable resizing, you can set the resize prop to none. This doesn't change
the amount of text you can enter, but only the visual appearance. The amount of
text can be adjusted using the cols and rows.
Restrict resizing to one direction
The TextArea component can be resized in both directions by default. However,
in case you need to resize in one direction only, you can set the resize prop
to horizontal or vertical.
Validation
For validation patterns including custom hints and errors, see
show custom hints and errors
in the FormField documentation.