---
title: Examples
slug: wip/mm7_-examples
createdAt: 2023-07-20T14:45:03.180Z
---

# Examples

## Basic Usage

A label will be displayed when provided via the `label` property.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/ZEMNNze/0d40c8ec7efc91b84834b743c7d644ab?default-tab=html%2Cresult&#x26;amp;theme-id=39623&#x26;amp;editable=true&#x22; height=&#x22;252px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Help Text & Placeholder

The help text and placeholder serve the purpose of guiding a user's input by providing additional information.

A help text provides more context as to why and how the data that is requested is relevant whereas a placeholder showcases an example of how data should be entered.

A help text can either be passed as an attribute for simple string-based content or via a slot for rich formatted content.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/zYJQQxP/d4ba47341d98b1ff69e41bcc55fa74e6?default-tab=html%2Cresult&#x26;amp;theme-id=39623&#x26;amp;editable=true&#x22; height=&#x22;461px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Required and Optional

Adding a required or optional label helps users to be guided while filling out a form. For example, Textareas are marked as "Required" when the majority of the fields in the same form are optional.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/PodvvGo/f9a7e2115b73587d1f5c6cae73ebe58c?default-tab=html%2Cresult&#x26;amp;theme-id=39623&#x26;amp;editable=true&#x22; height=&#x22;437px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## States

The Textarea supports a wide range of different states.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/gOdJJLY/c501b0738bb4626b9e22a722c1170181?default-tab=html%2Cresult&#x26;amp;theme-id=39623&#x26;amp;editable=true&#x22; height=&#x22;791px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Validation

A Textarea's validity can either be determined automatically when used inside a form or can be controlled from outside based on custom rules and application business logic.

### Inside a form

Textareas seamlessly integrate into a form's validation workflows and validate when a form is submitted. When no custom validation message is provided, the Textarea falls back to the browser's native validation message.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/abarryj/87eb38ac8bb22974395f6ff75669aee6?default-tab=html%2Cresult&#x26;amp;theme-id=39623&#x26;amp;editable=true&#x22; height=&#x22;311px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

### Inside an application

Textareas can be individually flagged as invalid based on custom rules or other business logic of an application. When flagged as invalid, a Textarea expects a descriptive validation message to be set alongside.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/bGxyyYe/79461531fe0c80a6e3552e9f00583e79?default-tab=html%2Cresult&#x26;amp;theme-id=39623&#x26;amp;editable=true&#x22; height=&#x22;316px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Height and Resizing

The Textarea comes with a default height to fit four lines of text. Their height can be either increased using the `rows` property or allow users to resize them by setting `resizable`

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/bGxyyMB/61f5da9afb9cfb0a7adb421d1f9a7eaf?default-tab=html%2Cresult&#x26;amp;theme-id=39623&#x26;amp;editable=true&#x22; height=&#x22;275px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Listening to Events

The Textarea supports the most commonly used events.

:::hint{type="info"}
**💡 Did you know?**

Some native events like `change` are blocked by the Shadow DOM boundary of the web component standard. Hence some of them are proxied through custom events.

Find out more: [Form Input Events & API](https://cosmos.redbull.design/wip/form-input-events-and-api)
:::

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/abarrEa/fb1a1a7229c8cdabec07cf8d6f64db8b?default-tab=html%2Cresult&#x26;amp;theme-id=39623&#x26;amp;editable=true&#x22; height=&#x22;454px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

