Skip to content

Text area - Elements ​

A text area allows users to input extended text content that covers multiple lines.

ElementsreleasediOSreleasedReactreleasedVuereleased

Accessibility ​

If a visible label isn't specified, an aria-label must be provided to the text field for accessibility. If the field is labeled by a separate element, an aria-labelledby property must be provided using the id of the labeling element instead.

  • Always provide a visible label (do not rely on placeholder alone).
  • Do not rely on color alone for interaction feedback (e.g. error states).

Usage ​

A multi-line text input with built-in form validation, auto-resizing, and styling support.

The component automatically handles:

  • Form integration
  • Auto-resizing based on content and row constraints
  • Built-in validation with customizable error messages
  • Accessibility attributes and labeling

Examples ​

html
<w-textarea label="Description"></w-textarea>

Placeholder ​

Text hint that appears when the textarea is empty. Placeholder text should not be used as a substitute for a visible label.

html
<w-textarea
    label="Description"
    placeholder="Give as much detail as you can"
></w-textarea>

Height ​

You can control the height of the input field by setting either minimum-rows or maximum-rows

html
<w-textarea label="Description" minimum-rows="3"></w-textarea>

With maximum-rows the content will start scrolling when it passes the limit. Note that the field stops being resizable. Setting minimum-rows is redundant when you set maximum-rows.

html
<w-textarea label="Description" maximum-rows="3" value="Line 1
Line 2
Line 3
Line 4
Line 5"></w-textarea>

Disabled ​

Consider using more informative alternatives before choosing to use disabled, as some users may not understand why an element is disabled.

html
<w-textarea
    label="Description" 
    value="This form field is ignored"
    disabled
></w-textarea>

Read only ​

Makes the textarea content immutable while remaining focusable. The contents can still be copied.

html
<w-textarea
    label="Description"
    value="This content is read only"
    readonly
></w-textarea>

Styling API ​

This section documents the supported styling hooks for <w-textarea>.

Use these hooks to customize appearance without relying on internal structure or selectors.

Before changing the default styles, remember that doing so can result in less consistent experiences for users across the product. Prefer defaults.

  • Prefer component tokens for size, spacing, and state styling.
  • Use parts only for small, local tweaks.
  • Avoid relying on internal class names or selectors.

Parts ​

The textarea exposes a minimal set of parts that can be targeted for last‑mile layout or typography tweaks.

PartTargetsTypical use
inputnative textarea elementminor typography or spacing tweaks

Example:

css
w-textarea::part(input) {
  letter-spacing: 0.5px;
}

Parts are intended as an escape hatch. Prefer component tokens for anything state‑ or size‑related.

Component tokens ​

Component tokens (--w-c-input-*) act as inputs to the textarea styling. They can be set directly on the component or inherited from a parent container.

These tokens are shared across textfield, textarea, and select for consistent form styling.

css
.form-section {
  --w-c-input-label-font-weight: 600;
  --w-c-input-help-text-color: var(--w-s-color-text);
}

Defaults are defined internally; setting a token is always optional.

Label tokens ​

TokenPurposeDefault
--w-c-input-label-colorlabel text color--w-s-color-text
--w-c-input-label-font-sizelabel font size--w-font-size-s
--w-c-input-label-line-heightlabel line height--w-line-height-s
--w-c-input-label-font-weightlabel font weight700
--w-c-input-label-padding-bottomspace below label0.4rem
--w-c-input-label-cursorcursor when hovering labelpointer
--w-c-input-label-displaylabel display modeblock

Optional indicator tokens ​

When optional attribute is set, these tokens control the "(optional)" text styling:

TokenPurposeDefault
--w-c-input-optional-coloroptional text color--w-s-color-text-subtle
--w-c-input-optional-font-sizeoptional text font size--w-font-size-s
--w-c-input-optional-line-heightoptional text line height--w-line-height-s
--w-c-input-optional-font-weightoptional text font weight400
--w-c-input-optional-padding-leftspace before optional text0.8rem

Help text tokens ​

TokenPurposeDefault
--w-c-input-help-text-colorhelp text color (normal state)--w-s-color-text-subtle
--w-c-input-help-text-color-invalidhelp text color when invalid--w-s-color-text-negative
--w-c-input-help-text-font-sizehelp text font size--w-font-size-xs
--w-c-input-help-text-line-heighthelp text line height--w-line-height-xs
--w-c-input-help-text-margin-topspace above help text0.4rem
--w-c-input-help-text-displayhelp text display modeblock

Implementation notes ​

Shared token system ​

Textarea shares its label, optional indicator, and help text tokens with w-textfield and w-select. This ensures consistent form styling across all text input components.

<w-textarea> API ​

Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).

Properties ​

NameTypeDefaultSummary
checkValidity (JS only)checkValidity() => boolean-Checks whether the textarea passes constraint validation
disabledbooleanfalseMakes the element not focusable and hides it from form submits
handler (JS only)handler(e: InputEvent) => void--
help-textstring | undefined-Description shown below the input field
invalidbooleanfalseMark the form field as invalid.
labelstring | undefined-Either a label or an aria-label must be provided.
maximum-rowsnumber | undefined-Sets the maximum number of text rows before the content starts scrolling.
minimum-rowsnumber | undefined-Sets the minimum number of text rows the textarea should display
namestring | undefined-The name of the input field when submitting the form
optionalbooleanfalseShow an icon behind the label indicating the field is optional
placeholderstring | undefined-Shown in the textarea when it doesn't have a value
read-onlybooleanfalseDeprecated: Use the native readonly attribute instead
readonlybooleanfalseWhether the input can be selected but not changed by the user
reportValidity (JS only)reportValidity() => boolean-Checks validity and shows the browser's validation message if invalid
requiredbooleanfalseWhether user input is required on the input before form submission
resetFormControl (JS only)resetFormControl() => void--
setCustomValidity (JS only)setCustomValidity(message: string) => void-Sets a custom validation message. Pass an empty string to clear.
validationMessage (JS only)string-Returns the validation message if the textarea is invalid, otherwise an empty string
validity (JS only)ValidityState-Returns the validity state of the textarea
valuestring | undefined-Lets you set the current value

Property Details ​

checkValidity (JS only) ​

Checks whether the textarea passes constraint validation

  • Type: checkValidity() => boolean
  • Default: -

disabled ​

Keep in mind that using disabled in its current form is an anti-pattern.

There will always be users who don't understand why an element is disabled, or users who can't even see that it is disabled because of poor lighting conditions or other reasons.

Please consider more informative alternatives before choosing to use disabled on an element.

  • Type: boolean
  • Default: false

handler (JS only) ​

  • Type: handler(e: InputEvent) => void
  • Default: -

help-text ​

Use in combination with invalid to show as a validation error message, or on its own to show a help text.

  • Type: string | undefined
  • Default: -

invalid ​

Mark the form field as invalid.

Make sure to also set a help-text to help users fix the validation problem.

  • Type: boolean
  • Default: false

label ​

Either a label or an aria-label must be provided.

  • Type: string | undefined
  • Default: -

maximum-rows ​

Sets the maximum number of text rows before the content starts scrolling.

  • Type: number | undefined
  • Default: -

minimum-rows ​

Sets the minimum number of text rows the textarea should display

  • Type: number | undefined
  • Default: -

name ​

The name of the input field when submitting the form

  • Type: string | undefined
  • Default: -

optional ​

Show an icon behind the label indicating the field is optional

  • Type: boolean
  • Default: false

placeholder ​

Set a text that is shown in the textarea when it doesn't have a value.

Placeholder text should not be used as a substitute for labeling the element with a visible label.

  • Type: string | undefined
  • Default: -

read-only ​

Deprecated: Use the native readonly attribute instead

  • Type: boolean
  • Default: false

readonly ​

Whether the input can be selected but not changed by the user

  • Type: boolean
  • Default: false

reportValidity (JS only) ​

Checks validity and shows the browser's validation message if invalid

  • Type: reportValidity() => boolean
  • Default: -

required ​

Whether user input is required on the input before form submission

  • Type: boolean
  • Default: false

resetFormControl (JS only) ​

  • Type: resetFormControl() => void
  • Default: -

setCustomValidity (JS only) ​

Sets a custom validation message. Pass an empty string to clear.

  • Type: setCustomValidity(message: string) => void
  • Default: -

validationMessage (JS only) ​

Returns the validation message if the textarea is invalid, otherwise an empty string

  • Type: string
  • Default: -

validity (JS only) ​

Returns the validity state of the textarea

  • Type: ValidityState
  • Default: -

value ​

Lets you set the current value

  • Type: string | undefined
  • Default: -

Questions? ​

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system