Textarea

<wa-textarea> Stable Since 2.0

Textareas collect data from the user and allow multiple lines of text.

<wa-textarea label="Type somethin', will ya"></wa-textarea>

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

Labels

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

<wa-textarea label="Comments"></wa-textarea>

Hint

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

<wa-textarea label="Feedback" hint="Please tell us what you think."> </wa-textarea>

Rows

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

<wa-textarea rows="2"></wa-textarea>

Placeholders

Use the placeholder attribute to add a placeholder.

<wa-textarea placeholder="Type something"></wa-textarea>

Appearance

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



<wa-textarea placeholder="Type something" appearance="filled"></wa-textarea><br />
<wa-textarea placeholder="Type something" appearance="filled-outlined"></wa-textarea><br />
<wa-textarea placeholder="Type something" appearance="outlined"></wa-textarea>

Disabled

Use the disabled attribute to disable a textarea.

<wa-textarea placeholder="Textarea" disabled></wa-textarea>

Value

Use the value attribute to set an initial value.

<wa-textarea value="Write something awesome!"></wa-textarea>

Sizes

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





<wa-textarea placeholder="Extra Small" size="xs"></wa-textarea>
<br />
<wa-textarea placeholder="Small" size="s"></wa-textarea>
<br />
<wa-textarea placeholder="Medium" size="m"></wa-textarea>
<br />
<wa-textarea placeholder="Large" size="l"></wa-textarea>
<br />
<wa-textarea placeholder="Extra Large" size="xl"></wa-textarea>

Prevent Resizing

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

<wa-textarea resize="none"></wa-textarea>

Expand with Content

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

<wa-textarea resize="auto"></wa-textarea>

Resize horizontal

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

<wa-textarea resize="horizontal"></wa-textarea>

Resize both

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

<wa-textarea resize="both"></wa-textarea>

Character Count

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.


<wa-textarea label="Comments" hint="Share your thoughts with us" with-count></wa-textarea>
<br />
<wa-textarea label="Bio" hint="Tell us a little about yourself" with-count maxlength="100"></wa-textarea>

Importing

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/webawesome@0.14.0/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

Learn more about using slots.

Attributes & Properties

Learn more about attributes and properties.

Methods

Learn more about methods.

Events

Learn more about events.

Custom States

Learn more about custom states.

CSS parts

Learn more about CSS parts.

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