Skip to main content

Textarea

scoped

Textarea extends the capabilities of the standard HTML textarea element. It adds styles to achieve a visually consistent user interface and offers features such as auto-height - adjusting the height of an element to the inserted text, or also a counter for inserted characters.

Basic usage

This example shows the textarea in its default state without a counter, auto-height, or other enhancements.

Standard

Adding the standard attribute will display a textarea in the style of the standard HTML textarea element.

Counter

Adding the counter attribute will display a counter below the textarea showing the number of characters inserted and the maximum number of characters allowed. It is to be used in combination with the max-length property. Otherwise, the maximum number allowed will be set to 1000.

Resize (none)

The resize property specifies the behavior of element resizing. If set to none, the field size remains fixed.

Resize (auto)

If the resize property is set to auto, the size of the element is automatically adjusted to the inserted content.

Disabled

When the disabled attribute is inserted into the textarea element, it will not be possible to write.

When to use

Use wje-textarea when users need to enter values, choose options, or trigger form-related actions.

When not to use

Do not use it as a decorative element without interaction. Prefer presentational components in that case.

Accessibility

Always provide a label (label/aria-label), keep keyboard support, and surface clear validation feedback.

Best Practices

  • Keep validation rules and error behavior consistent across the entire form.
  • Show loading or disabled states during async operations.
  • Split complex forms into smaller sections with immediate feedback.

Attributes and Properties

disabled

DescriptionDisables user interaction with the component.
Attributedisabled
Typeboolean
Default-

invalid

DescriptionControls validation or status messaging for invalid.
Attributeinvalid
Typeboolean
Defaultfalse

label

DescriptionRetrieves the value of the 'label' attribute if it exists. If the 'label' attribute is not set, it returns false.
Attributelabel
Typestring
Defaultfalse

name

DescriptionSets the field name used when submitting form data.
Attributename
Typeany
Default-

placeholder

DescriptionSets placeholder text shown when the value is empty.
Attributeplaceholder
Typeany
Default-

readonly

DescriptionPrevents the value from being edited by the user.
Attributereadonly
Typeboolean
Default-

required

DescriptionMarks the component as required for form validation.
Attributerequired
Typeboolean
Default-

rows

DescriptionSets the number of visible text rows.
Attributerows
Typeany
Default-

validateOnChange

DescriptionSets the validateOnChange property. If set to a truthy value, it adds the validate-on-change attribute to the element. If set to a falsy value, it removes the validate-on-change attribute from the element.
Attributevalidate-on-change
Typeboolean
Defaultfalse

value

DescriptionGetter for the value attribute.
Attributevalue
Typestring
Default-

Events

NameDescription
wje-textarea:changeEmitted when the component value changes.
wje-textarea:inputEmitted when the input value changes.

Methods

No public methods available for this component.

CSS Shadow Parts

NameDescription
nativeThe native textarea wrapper.
inputThe textarea input.
wrapperThe textarea wrapper.

CSS Custom Properties

NameDescription
--wje-textarea-font-familySpecifies the font family used for the textarea. Accepts any valid CSS font-family value.
--wje-textarea-background-colorSets the background color of the textarea. Accepts any valid CSS color value.
--wje-textarea-colorDefines the text color within the textarea. Accepts any valid CSS color value.
--wje-textarea-color-invalidChanges the text color of the textarea when it is invalid. Useful for highlighting validation errors.
--wje-textarea-border-widthSpecifies the width of the textarea's border. Accepts any valid CSS length unit.
--wje-textarea-border-styleSets the style of the textarea's border. Accepts standard CSS border styles such as solid, dashed, or dotted.
--wje-textarea-border-colorDefines the border color of the textarea. Accepts any valid CSS color value.
--wje-textarea-border-color-focusSpecifies the border color of the textarea when it is focused. Enhances the user experience by providing visual feedback.
--wje-textarea-border-radiusDetermines the border radius of the textarea, defining how rounded its corners are. Accepts any valid CSS length unit.
--wje-textarea-margin-bottomSets the bottom margin of the textarea. Ensures spacing between the textarea and other elements.
--wje-textarea-line-heightSpecifies the line height of the text within the textarea. Helps control the vertical spacing of the text.
--wje-textarea-paddingDefines the padding inside the textarea. Controls the spacing between the content and the border.

Slots

No slots available for this component.