docs / core / textarea
Textarea
text that runs past one line. same surface, focus ring and invalid state as Input, and it can grow with what you type.
intensity · recedesrsc · client
provenance
authored in usvalayer
core / primitivesintensity
recedes · safe anywhere, including dense surfacescomposition
under a Label, inside a FieldGroup, with FieldCount for a limitautoGrow with a maxRows, so a long answer never eats the pagenot for one line. that is an Input, however wide you make itautoGrow without maxRows in a short form. it will run off screena11y
a native<textarea>, named by a Label or aria-label · aria-invalid paints the danger state · autoGrow only changes height, never focus or caretjest-axelive demo · try it out
customize
placeholderhint text, never a label
valuethe starting text
autoGrowgrow with the content instead of scrolling
minRowsshortest it ever gets
maxRowswhere it stops growing and starts scrolling
invalidsets aria-invalid, paints danger
disableddims to 50%, not-allowed cursor
usage
import { Textarea } from "@usva-ui/react/primitives/textarea";
<Textarea placeholder="Tell us about yourself…" rows={3} />props
| prop | type | default | notes |
|---|---|---|---|
| autoGrow | boolean | false | grows with the content instead of scrolling. off by default, so height stays yours. |
| minRows | number | 2 | shortest the field ever gets. also seeds the rows attribute under autoGrow. |
| maxRows | number | — | where growing stops and scrolling starts. unbounded when unset. |
| aria-invalid | boolean | false | danger border and ring for the field the error text points at. |
| disabled | boolean | false | dims to 50% with a not-allowed cursor. |
| …TextareaHTMLAttributes | React.TextareaHTMLAttributes | — | every native textarea attribute passes straight through. |
get it
bun add @usva-ui/reactusage
import { Textarea } from "@usva-ui/react/primitives/textarea";
<Textarea placeholder="Tell us about yourself…" rows={3} />
<Textarea autoGrow minRows={2} maxRows={10} />
<Textarea aria-invalid defaultValue="Too short." />
<Textarea disabled defaultValue="Read only for now." />