Skip to the content

TextArea

TextArea is the multi-line text field, a native <textarea> with the input size and state tokens. With maxLength it shows a remaining-characters counter, controlled or not.
Forms

When to use

Use when
  • Collecting comments, descriptions or messages that may span several lines.
  • An editor should take the full height of its pane (fill).
Avoid when

Usage

140 characters left
<TextArea aria-label="Comment" placeholder="Leave a comment" maxLength={140} />

maxLengthHint sets the counter suffix (default characters left). resize enables the manual resize handle. As on Input, a native constraint paints the error border after interaction (:user-invalid) unless you pass an explicit variant.

Auto-resize

autoResize grows the field with its content, from rows up to an optional maxRows. It uses field-sizing: content; browsers without it keep the rows height. It turns resize off.

<TextArea aria-label="Description" rows={2} autoResize maxRows={6} />

Fill

fill makes the field take the leftover height of its flex parent, with rows as the minimum. Inside a Field, pass it through inputProps: label and hint keep their height. Every ancestor up to the sized pane must be a flex container. fill wins over autoResize (with a development warning) and turns resize off.

2000 characters left
<Flex height="100dvh">
  <Field component={TextArea} name="content" label="Content" inputProps={{ fill: true, rows: 4 }} />
</Flex>

Accessibility

  • TextArea renders no label: use Field or pass aria-label.
  • The counter is visible text only; it is not announced as the user types.

Properties

See also