Textarea
Textareas capture multi-line user input such as comments, notes, or descriptions.
Component variations
Basic Textarea
Standard textarea for multi-line input
States
Contains: Default, Success, Error, Warning
Optional & Disabled
Textarea can be marked as optional or disabled
Optional
Character Limit
Textarea can have a maximum character count with counter
Hint & Helper Text
Use hint for tooltips and helper text for guidance
With Icons
Textarea with leading icon
Trailing Action
Textarea with trailing action icon for buttons like send or submit
Usage Guidelines
Import
Import the textarea component in your module or component:
import-textarea.ts
Copy code
Basic Implementation
Here is a basic example of using the textarea component:
textarea-example.ts
Copy code
Implementation with all available APIs
Here is an example of using the textarea component with all available APIs:
textarea-example.html
Copy code
Listening to Events
Handle input changes by listening to the (valueChange) and (valueCommit) events:
textarea-events.html
Copy code
textarea-events.ts
Copy code
Using Character Limits
Control maximum character input and display a counter:
textarea-character-limit.html
Copy code
Using Trailing Action
Add a trailing action icon for buttons like send, submit, or attachment:
textarea-trailing-action.html
Copy code
textarea-trailing-action.ts
Copy code
API Reference
Inputs
Property | Type | Default | Required | Description |
|---|---|---|---|---|
string | - | No | Label text displayed above the textarea | |
string | '' | No | Placeholder text shown when textarea is empty | |
string | '' | No | Current value of the textarea | |
boolean | false | No | Whether the textarea is optional | |
boolean | false | No | Whether the textarea is disabled | |
'success' | 'error' | 'warning' | null | null | No | Visual state of the textarea | |
string | - | No | Helper text displayed below the textarea | |
string | - | No | Hint text shown in tooltip | |
string | - | No | Icon displayed before the textarea value | |
string | - | No | Icon button displayed after the textarea value |
Outputs
Event | Type | Description |
|---|---|---|
EventEmitter<string> | Emitted on every textarea input change | |
EventEmitter<string> | Emitted when the textarea loses focus | |
EventEmitter<void> | Emitted when the trailing action icon is clicked | |
EventEmitter<void> | Emitted when the textarea receives focus |
Best Practices
When to Use
- Use Textarea when this pattern clearly supports the user task.
- Use it to keep similar interactions consistent across the product.
When Not to Use
- Avoid using Textarea when a simpler component communicates the same intent.
- Avoid using it when the pattern introduces unnecessary interaction steps.
Design Guidelines
- Use textareas for multi-line input like comments, descriptions, or feedback
- Provide clear labels that describe the expected content
- Use placeholder text to give users hints about format or content
- Set appropriate maxInputCount for character-constrained fields
- Use helper text to guide users on expected content length or format
- Show validation feedback with state prop and helper text
- Consider default height that accommodates typical input
- Keep labels, helper text, and actions concise and easy to scan.
- Use VD variants and states consistently for predictable behavior.
- Ensure keyboard access and clear focus order for accessibility.
Component playground
Customize the textarea features in this section
example.html
Copy code