Textarea
Edit multi-line text with optional auto-sizing and Field integration.
Anatomy#
Usage#
Use Textarea for multi-line native text entry. Use Input for a single line. Use InputGroup to put controls around it without changing which element receives typing and focus.
Native attributes#
Textarea forwards native textarea attributes and works with controlled or uncontrolled values.
Pair value with onValueChange for controlled text, or use defaultValue; a native form reset
restores defaultValue.
A controlled textarea restores its displayed text to value after every edit, so update value
from onValueChange. Use readOnly to preserve selection and focus without edits, or disabled to
prevent interaction.
modifiers works as on Input: trim, lazy, number, and
empty transform the text before onValueChange and form state. In Textarea, trim and lazy
apply on change (blur).
Size and composition#
rows sets the visible height (default 3). Set autoResize to grow the textarea with its content:
it never shrinks below rows, and maxRows caps the growth before it scrolls (0, the default, is
unlimited). autoResizeDelay postpones the first resize after mount.
Use InputGroup orientation="vertical" with Leading and Trailing for header and footer regions.
Your application owns counters, submit buttons, and keyboard shortcuts.
Examples#
Auto-resize#
Enable autoResize and cap vertical growth with maxRows.
Header and footer#
Use a vertical InputGroup for a header, a footer, or both around the textarea. The textarea still owns the value.
Character count#
Keep the count in application state. InputGroup.Trailing is a place to render it; Moraine has no
built-in counter.
Form#
Place Textarea in form.Field so schema validation owns the error.
API Reference#
Attributes#
data-autoresizedata-disableddata-invaliddata-readonlydata-requiredProps#
Props for the Textarea component.