Textarea
Accept multiple lines of text, such as descriptions, notes, or messages.
Usage guide
#Accept long, multiline text, such as notes or detailed descriptions. Use Input for a single line.
Write the error message in the error slot.
Inside the component, add <span slot="error">Error message</span>. You can include links and other guidance as well as text. For inputs supporting noNativeValidity, enable it to show this guidance instead of a browser popup. Switch always displays errors below the component.
Report business rule failures with setCustomError().
For example, if the server rejects a duplicate value, update the error slot and call setCustomError(). This method does not take a message argument. A custom error also blocks form submission.
Clear the error after resolving it and check whether submission is allowed.
Use clearCustomError() to clear a business rule error. Required-field and format validation remain active. await checkValidity() returns true or false; reportValidity() validates and displays errors. Read valid named values through FormData on submission.
- Input area
- Set the initial height with
rows.resize="vertical"allows height adjustment while preserving width. - Length guidance
- Show the character count with
counterand limit length withminandmax. - Required
- Use
requiredto validate empty submissions and provide error feedback.
Examples
#Feature examples
#Choose a feature from 28 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.
No matching features.
API reference
#Hover over a name or focus it with the keyboard to see the code. On touch screens, tap the name.
<sy-textarea>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
boolean | false | Focus the input when it first connects. | |
boolean | false | Hide the default border. | |
boolean | false | Show a button to clear the current value. | |
boolean | false | Show the input character count. | |
boolean | false | Block user interaction and keyboard focus. | |
string | "" | Label describing the item. | |
number | Number.MAX_SAFE_INTEGER | Maximum input character count. | |
number | 0 | Minimum required character count. | |
string | "" | Placeholder shown when the value is empty. | |
boolean | false | Display the current value while preventing edits. | |
boolean | false | Fail form validation when no value is provided. | |
"none" | "horizontal" | "vertical" | "both" | "none" | Directions in which the user can resize. | |
number | 4 | Default number of rows in the input area. | |
"small" | "medium" | "large" | "medium" | Component size. | |
'default' | 'warning' | 'error' | 'success' | 'default' | Visually represent default, success, warning, or error states. | |
string | "" | Current value or item identifier. | |
string | "" | Field name used in FormData. | |
boolean | false | Use the app's error UI instead of the browser's built-in error display. checkValidity still performs validation. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<{ value: string; length: number; isValid: boolean; status: string }> | Emitted when the value or selection state changes. | |
CustomEvent<{ value: string; isValid: boolean; status: string }> | Emitted when focus is lost. | |
CustomEvent<{ value: string; isValid: boolean; status: string }> | Emitted when focus is received. |
Methods
| Method | Returns | Description |
|---|---|---|
Promise<void> | Move keyboard focus to the input or action element. | |
Promise<void> | Remove focus from the input element. | |
Promise<boolean> | Return true if the current constraints are satisfied, otherwise false. | |
Promise<boolean> | Validate the current value and display errors to the user. | |
Promise<void> | Set a custom error state. | |
Promise<void> | Clear the custom error state. | |
Promise<"" | "custom" | "valueMissing" | "tooShort" | "tooLong"> | Return the current validation state. |
Slots
| Slot | Description |
|---|---|
| Validation error message. |