Components · Form

Text area

A text area lets the user enter text over multiple lines: comments, feedback or longer passages that need more room than a single-line input.

How to add a text area to a page. The file is components/css/textarea.css.

Basic Usage

Link the shared stylesheet once per page, and add the keyboard script and, for a word count, the count script. Never copy the rules into a page.

StepWhat to do
1. Link<link rel="stylesheet" href="/components/css/textarea.css">. Both templates already have it.
2. MarkupA form-field with a label, an input-wrap around the textarea.form-textarea, and an optional form-helper message.
3. Word countPut the label and a span.form-count in a div.form-field__head, set maxlength, and bind the count (script under CSS / Tailwind).
4. Keyboard focusAdd the script under CSS / Tailwind once per page. Without it the ring never shows on keyboard focus.

Text area

Copy the markup you need. Hover and focus come from :hover and keyboard focus; the [data-state] selectors in the CSS exist only so the documentation can force a state.


API

Classes

ClassUse
form-fieldThe column: label row, wrapper, message.
form-field__headThe label row, with the word count on the right.
form-labelThe label. Use form-label--sm from input.css for the small label of a docs control.
form-countThe word count.
input-wrapThe wrapper that draws the focus ring.
form-textarea, --error, --successThe text area and its error and success border.
form-helper, --error, --success, --disabledThe message.

Things to know

  • The Active border (black) comes from :placeholder-shown, so the placeholder is required.
  • Resize is vertical only (resize: vertical) and never goes below 66px.
  • The word count is not automatic: bind it with the script under CSS / Tailwind and set maxlength to match.
  • The [data-state] selectors do nothing outside the documentation pages.

CSS / Tailwind

The component is one CSS file, shared by every page. Link it, never copy it. The CSS below is read from the file the page links, so it is always what you see.

CSS (components/css/textarea.css)
JavaScript (focus ring on keyboard only, word count)