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 text behavior#
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#
Draft a release announcement#
Turn on autoResize and cap growth with maxRows. Keep the draft in local state.
Chat, message, and code panes#
Use a vertical InputGroup for a header, a footer, or both around the textarea. The textarea still owns the value.
Count remaining characters#
Keep the count in application state. InputGroup.Trailing is a place to render it; Moraine has no
built-in counter.
Bind a description field#
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. Renders a <textarea> element by default.