Textarea

<wa-textarea> Stable Since 2.0

Textareas collect multi-line text input from the user, with optional resizing and character counting.

This component works with standard <form> elements. Please refer to the section on form controls to learn more about form submission and client-side validation.

Examples

Link to This Section

Labels

Link to This Section

Use the label attribute to give the textarea an accessible label. For labels that contain HTML, use the label slot instead.

Hint

Link to This Section

Add descriptive hint to a textarea with the hint attribute. For hints that contain HTML, use the hint slot instead.

Rows

Link to This Section

Use the rows attribute to change the number of text rows that get shown.

Placeholders

Link to This Section

Use the placeholder attribute to add a placeholder.

Appearance

Link to This Section

Use the appearance attribute to change the textarea's visual appearance.



Disabled

Link to This Section

Use the disabled attribute to disable a textarea.

Value

Link to This Section

Use the value attribute to set an initial value.

Sizes

Link to This Section

Use the size attribute to change a textarea's size.





Prevent Resizing

Link to This Section

By default, textareas can be resized vertically by the user. To prevent resizing, set the resize attribute to none.

Expand with Content

Link to This Section

Textareas will automatically resize to expand to fit their content when resize is set to auto.

Resize horizontal

Link to This Section

Textareas can be made to resize horizontally when resize is set to "horizontal"

Resize both

Link to This Section

Textareas can be made to resize both vertically and horizontally when resize is set to "both"

Character Count

Link to This Section

Add the with-count attribute to show a character count below the textarea. When combined with maxlength, the count shows remaining characters instead. The count is exposed to assistive technologies using a live region so screen readers can announce updates as the user types.


Importing

Link to This Section

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.

CDN npm Self-Hosted React

Import this component directly from the CDN:

import 'https://ka-f.webawesome.com/[email protected]/components/textarea/textarea.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/textarea/textarea.js';

If you're self-hosting Web Awesome, import this component from your server:

import './webawesome/dist/components/textarea/textarea.js';

To import this component for React 18 or below, use the following code:

import WaTextarea from '@awesome.me/webawesome/dist/react/textarea/index.js';

Slots

Link to This Section

Learn more about using slots.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

Methods

Link to This Section

Learn more about methods.

Events

Link to This Section

Learn more about events.

Custom States

Link to This Section

Learn more about custom states.

CSS parts

Link to This Section

Learn more about CSS parts.

Need a hand? Report a bug Ask for help
    No results