Textarea
A field for a few sentences: the same .control box, taller, with an optional character counter. Say the limit before people reach it.
Usage
Use it when
- People write more than one line: a note to an adviser, a reason for a request, a report of a mistake in a question.
- A field has a character limit and people need to see how much room is left (
.counter).
Use something else when
- One short line (a name, a title, an email): use Text field.
- Writing a chat message that sends on Enter: use Composer.
- Long formatted content (an article, lesson notes): use Prose. Use a real editor; the textarea is plain text only.
- Editing a short value in place inside a list or table: use Inline edit.
- Several short items like topics or emails: use Tag input.
Where it goes. In a form, usually last before the actions, full width of the form column. In a dialog or modal for "report a mistake" style flows.
Examples
maxlength the browser stops input at the limit, so the counter never needs an over-limit state.
Your adviser reads this before the meeting.
<div class="field">
<label class="field__label" for="note">Note to your adviser <span class="counter" id="note-count">0 / 280</span></label>
<div class="control control--area">
<textarea id="note" maxlength="280" aria-describedby="note-help note-count"></textarea>
</div>
<span class="field__help" id="note-help">Your adviser reads this before the meeting.</span>
</div>
<!-- Update #note-count on input in your own code. -->
Describe the mistake, for example which option should be correct and why.
<div class="field" style="max-width: 520px;"> <label class="field__label" for="ta-why">What is wrong with this question?</label> <div class="control control--area is-invalid"><textarea id="ta-why" rows="4" aria-invalid="true" aria-describedby="ta-why-help"></textarea></div> <span class="field__help field__help--error" id="ta-why-help"><span class="ic" aria-hidden="true">error</span>Describe the mistake, for example which option should be correct and why.</span> </div>
Anatomy
| Part | What it is |
|---|---|
.field / .field__label / .field__help | Required. Same wrapper as a text field. |
.control.control--area | Required. The box grows to its content height, padded 12 by 14. |
textarea | Required. At least 88 px tall (about 3 lines), 22 px line height, not resizable by drag. Set rows for a taller start. |
.counter | Optional. Tabular "120 / 280" inside the label span, right-aligned by the label. |
States
| State | How |
|---|---|
focus / hover | As the text field: accent edge and halo on :focus-within. |
.is-invalid + aria-invalid | Danger edge and halo; message in .field__help--error. |
.is-disabled + disabled | Fill background and muted text. |
Motion and microinteractions
- Border and halo transition in
--d-fast(160 ms) on--ease-standard, like every.control. - The counter changes number in place; it does not animate.
- Reduced motion: transitions become 120 ms linear.
Accessibility
- A
<label for>names it; the helper and the counter are both inaria-describedbyso the limit is announced. - Prefer
maxlength(the browser stops input) and say the limit up front; if you allow going over and block on submit, markaria-invalidand say how many characters to remove. - Enter makes a new line. Never submit a textarea on Enter; that is the composer pattern.
- Text renders at 16 px on touch screens, so iOS does not zoom on focus.
Do and don't
Do
- Start it at the height of the expected answer (
rows="4"for a paragraph). - Show the counter only when there is a limit worth knowing.
Don't
- Allow the native drag handle or set a fixed tiny height; the box is sized by rows.
- Use a textarea for a single value people expect to fit on one line.
Behavior and code
Plain HTML. None. Update the .counter text on input in your own code.