Text area

A native multi-line text editor bound to Field behavior for labels, limits and validation.

<tp-text-area>
Text area
Default density Compact density Restart from the initial state Show the copyable source

Usage

Text area shares Input’s value, editing and form model, but keeps newlines: Enter inserts a line instead of submitting. Labels, descriptions and errors belong to tp-field; a standalone Text area can take label for its accessible name.

Sizing

Content and fixed sizing
Default density Compact density Restart from the initial state Show the copyable source

The default theme sizes the editor to its content from a minimum height, so short replies stay compact and long ones never scroll. For a fixed height, set native fixed sizing through hostProperties and choose the height with rows. resize follows writing mode: block (the default) lets people drag it taller, none removes the handle, and inline or both allow width changes.

Code-like values

mono shows the value in the mono font and turns off spell checking, autocorrection and autocapitalization, for JSON, queries and other text where autocorrection would break the value.

Mono
Default density Compact density Restart from the initial state Show the copyable source

Validation

Native constraints such as required, minlength and maxlength validate through the owning Field, which shows the error and wires aria-describedby.

Error
Default density Compact density Restart from the initial state Show the copyable source

Listening to changes

Character count
Default density Compact density Restart from the initial state Show the copyable source
68 / 280

Typing, pasting and clearing each publish a cancelable tp-value-change with the proposed value. Use it for live counters or previews; calling preventDefault() rolls the edit back. Controlled mode stays fixed for a lifetime; rejected edits restore committed text without unnecessary selection changes. Composition remains one edit.

Forms

Form
Default density Compact density Restart from the initial state Show the copyable source
Send reply Discard

The native textarea renders in light DOM and submits with its form; Reset restores default-value. Uncontrolled reset uses form-reset, while controlled reset preserves owner text without a synthetic proposal. Form restoration restores uncontrolled strings.

States

Disabled and read-only
Default density Compact density Restart from the initial state Show the copyable source

Disabled omits the value from form data. Read-only keeps it, along with selection and focus.

API Reference

Every element also accepts motion-policy.

Attributes

AttributePropertyTypeDefaultDescriptionrowsrowsnumber2The visible number of text lines before the content scrolls.resizeresize'none' | 'block' | 'inline' | 'both''block'Which directions the user can drag the corner to resize the editor.

Events

EventTypeDescriptiontp-value-changeTpValueChangeEvent<string>Cancelable proposal of new text before it commits; detail.value, detail.previousValue and the detail.reason for the change.tp-field-valueCustomEvent<{ value: string; previousValue: string; reason: ChangeReason; }>After new text commits, with the same value, previousValue and reason; the enclosing Field listens for it.

Slots

SlotDescriptiondefaultHolds the native textarea the element renders; leave it empty.

Components, widgets and patterns that use this one.