Skip to content

role textarea

Textarea draft v0.1.0

Lets people enter or edit several lines of text.

A textarea collects free text that may run over several lines: a message, a description, a comment, an address. It shows a chosen number of lines, scrolls beyond them and can be resized. It has a visible label above, an optional description and, when its value fails validation, an error message under it. One line of text is a Text field.

Guidelines

From apps/docs/content/components/textarea.md

Overview

A textarea collects free text that may run over several lines: a message, a description, a comment, a postal address. It shows a chosen number of lines, scrolls beyond them and can be resized vertically. Everything else works like the Text field: a visible label above, help text under, and an error message that says how to fix the value.

This page applies to every platform. Where a platform differs, the difference sits under a sub-heading named after it (Web, iOS, Android, Desktop); everything else holds everywhere.

When to use

  • Text longer than a short phrase, or where line breaks matter: messages, descriptions, notes.
  • Pasted content people may want to review in full (a key, an address).

When not to use

  • One line of text. Use a Text field: a tall box invites long answers.
  • Formatted text (headings, lists). That is a rich text editor, not a textarea.

Sizes

Size Use for
Small Dense forms, toolbars and table rows: 32 px high with 14 px text.
Medium Forms, the default: 40 px high with 16 px text.
Large A prominent single field, such as a search page or a sign-in form: 48 px high with 20 px text.

Height, inline padding and text size scale together; the label, the description and the error message keep one size. The exact values are tokens (Tokens tab). Keep one size per form.

Rows

The rows property sets how many lines are visible before the box scrolls; three by default. Choose it from the expected length of the answer, and let people resize the box vertically when they write more. The box never resizes horizontally: it fills the width the layout gives it.

States

State How it happens What changes
Default Resting. An outlined box on the default surface.
Hover A pointer rests over the box. Needs a pointing device: there is no hover on touch. The box takes the surface hover tint; the border does not change.
Focus visible The box has focus, from the keyboard or a pointer. The shared focus ring appears outside the border.
Invalid invalid property, after validation. The border takes the error color and the error message appears under the box.
Read-only readonly property. The box takes the level 1 surface; the text can still be focused, read and copied.
Disabled disabled property. Box, text, label and description drop to the shared disabled colors; the field leaves the keyboard order.

Content

  • The label is a noun phrase: Message, Description, Delivery notes.
  • The description says what to include or a length limit: Up to 500 characters.
  • The error message says what is wrong and how to fix it: Enter a message of at least 20 characters.

Accessibility

The Specification tab lists the full accessibility contract, grouped into what holds on every platform and what is specific to one. Each statement there links the source it comes from. This section explains the decisions behind it.

Web

iOS

Android

  • Text field (one line of text)