Textarea

Several lines of text. The Input's glass squircle field, growing with what's typed from three lines to about eleven, then scrolling. Built on the vendored textarea; every native attribute passes through.

Playground

Textarea
State

In a field

Like any control, it takes a FieldLabel and, when it helps, a description of what the text is for. Type a few lines — the field grows to fit, then scrolls.

The agent uses this to answer questions about you. Parking, the entrance, what to bring.

With a limit

maxLength stops the text at the limit; say how much is left in the description so the limit never comes as a surprise.

280 characters left

One line that wraps

size="sm" starts one line tall, as an sm Input beside it, and grows as its words wrap — for a short text in a row of Inputs that would otherwise be cut off on a phone, as a service's name on ServicesCard. It stays one line of text: Enter saves rather than breaking the line.

Invalid & disabled

Invalid is aria-invalid with a FieldError that says what to change; disabled dims the field.

API reference

PropTypeDefaultDescription
size"sm" | "md""md"md: three lines to about eleven. sm: one line at an sm Input's 32px, growing as its words wrap.
aria-invalidbooleanfalseMarks the text wrong: a destructive edge. Pair with a FieldError and aria-describedby.
maxLengthnumber—Stops the text at this many characters. Show what's left in a FieldDescription.
rowsnumber—The starting height, only where the browser can't size the field to its content.
disabledbooleanfalseDisables and dims the field.
classNamestring—Layout only — width, margins, a taller min-h. Never restyle the field here.

Everything else passes through to the <textarea>: id, name, value, onChange, placeholder, readOnly, ref, …

Guidelines

  • Reach for Textarea when the answer is sentences — a venue description, a note for the stylist. A name, a phone number or a slug is an Input, even when it could be long.
  • Label it like any field, and use the placeholder for an example of a good answer, not instructions.
  • Enter makes a new line. Submit with the form's button; ⌘/Ctrl+Enter may submit as a shortcut, never plain Enter.
  • If there's a limit, set maxLength and count down in the description from the start — don't reveal it only when it's hit.