Skip to main content

Text Area

A multi-line plain-text editing control. Pair it with Field to connect its label, description, and errors in a form.

Desktop viewport
Tablet viewport
Mobile viewport

When to use

  • Accept several lines of free-form text, such as a comment on a review or a feedback form.
  • Prefer Input when the text fits on one line.

Appearance

Set appearance="monospaced" to render the text in a fixed-width font.

Desktop viewport
Tablet viewport
Mobile viewport

Height

The field grows with its text up to 15rem, then scrolls. Set rows to set its minimum height in lines, such as rows={2} for a short prompt. Without rows, the minimum height is 6rem. The person can drag the resize handle to make the field taller, but not shorter than the minimum.

Desktop viewport
Tablet viewport
Mobile viewport

Set a max-h-* class to change the height where the field stops growing. A rows minimum taller than that cap wins. After a drag on the resize handle, the field keeps the height the person chose and does not grow. Browsers without field-sizing keep the rows height and scroll.

Validation

Set validation to show the validation status of the text area.

Desktop viewport
Tablet viewport
Mobile viewport

Without a Field

Render the control on its own, and give it an accessible name with aria-label.

Desktop viewport
Tablet viewport
Mobile viewport

Examples

TextArea in a form with client-side validation

In this example, the TextArea is used in a form with client-side validation. The form is built using @tanstack/react-form and zod for validation. The form accepts user feedback and validates the input before submission.

Desktop viewport
Tablet viewport
Mobile viewport

API Reference

TextArea

A multi-line plain-text editing control.

All props from textarea, plus:

PropTypeDefaultDescription
appearance?"monospaced"Defines the visual style of the TextArea.
rows?numberThe minimum height of the field in lines. Without rows, the minimum height is 6rem.
validation?"error" | "success" | "warning" | false | (() => "error" | "success" | "warning" | false)Use the validation prop to show if the textarea has a specific validation status. This will change the border and outline of the textarea. The false type is useful when using short-circuiting logic so that you don't need to use a ternary with undefined. Setting validation to error also sets aria-invalid.
Data AttributeValueDescription
data-slot"text-area"The <textarea>.
data-validation"error" | "success" | "warning"The resolved validation. Omitted when unset.
data-drag-overpresent during a dragPresence-only. A drag holds content over the text area. The border turns dashed.