Textarea

Accept multiple lines of text, such as descriptions, notes, or messages.

Live preview
Interact with the component to see results here.
View code
HTML
<sy-textarea
  label="Project description"
  placeholder="Tell us about your project"
  rows="4"
  max="200"
  resize="vertical"
  size="medium"
  counter
  id="sample"
  name="description"
></sy-textarea>

Usage guide

#

Accept long, multiline text, such as notes or detailed descriptions. Use Input for a single line.

  1. 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.

  2. 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.

  3. 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 counter and limit length with min and max.
Required
Use required to validate empty submissions and provide error feedback.

Feature examples

#

Choose a feature from 28 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.

Usage examples · Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Property · Autofocus

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Borderless

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Clearable

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Counter

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Disabled

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Label

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Max

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Min

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · No Native Validity

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Placeholder

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Readonly

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Required

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Resize

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Rows

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Size

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Status

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Value

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Methods · Check Validity

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · Get Status

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · Report Validity

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · Set Blur

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · Set Custom Error

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · Set Focus

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Events · Blured

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Changed

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Focused

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Usage examples · Clear existing text

Use the clear control to remove a prefilled project description.

View code
HTML
<sy-textarea
  label="Project description"
  placeholder="Tell us about your project"
  rows="4"
  max="200"
  resize="vertical"
  size="medium"
  counter
  clearable
  value="A shared workspace for the design team."
  id="sample"
  name="description"
></sy-textarea>

<script type="module">
  const component1 = document.querySelector("#sample");
  Object.assign(component1, {
    "clearable": true,
    "value": "A shared workspace for the design team."
  });
</script>

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 / PropertyTypeDefaultDescription
booleanfalseFocus the input when it first connects.
booleanfalseHide the default border.
booleanfalseShow a button to clear the current value.
booleanfalseShow the input character count.
booleanfalseBlock user interaction and keyboard focus.
string""Label describing the item.
numberNumber.MAX_SAFE_INTEGERMaximum input character count.
number0Minimum required character count.
string""Placeholder shown when the value is empty.
booleanfalseDisplay the current value while preventing edits.
booleanfalseFail form validation when no value is provided.
"none" | "horizontal" | "vertical" | "both""none"Directions in which the user can resize.
number4Default 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.
booleanfalseUse the app's error UI instead of the browser's built-in error display. checkValidity still performs validation.

Events

EventDetailDescription
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

MethodReturnsDescription
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

SlotDescription
Validation error message.