Liking cljdoc? Tell your friends :D

x-text-area

A form-associated multi-line text input web component. Wraps a native <textarea> inside shadow DOM with support for labels, hints, error states, and full HTML form integration.

Tag Name

<x-text-area></x-text-area>

Attributes

AttributeTypeDefaultDescription
labelstring""Visible label text. Hidden when absent or empty.
namestring""Form field name used in FormData.
valuestring""Current text value. Syncs with textarea's live value.
placeholderstring""Placeholder text shown when the field is empty.
hintstring""Helper text displayed below the textarea.
errorstring""Error message. Non-empty triggers the invalid visual state.
disabledbooleanabsentDisables the textarea (presence = true).
readonlybooleanabsentMakes the textarea read-only (presence = true).
requiredbooleanabsentMarks the field as required for form validation.
rowsinteger3Number of visible text lines.
maxlengthintegerabsentMaximum number of characters allowed.
minlengthintegerabsentMinimum number of characters required.
autocompletestring""Autocomplete hint (e.g. "off", "on").
resizeenum"vertical"Controls CSS resize handle. One of: "none", "vertical", "horizontal", "both".

Properties

PropertyTypeReflectsDescription
valuestringvalueLive text value. Getter reads from textarea.value. Setter updates both attribute and DOM.
namestringnameForm field name.
disabledbooleandisabledDisabled state.
readOnlybooleanreadonlyRead-only state.
requiredbooleanrequiredRequired state.
rowsnumberrowsVisible row count (default 3).
maxLengthnumbermaxlengthMaximum character count. Returns null when not set.
minLengthnumberminlengthMinimum character count. Returns null when not set.
autocompletestringautocompleteAutocomplete hint.

Events

EventBubblesComposedCancelableDetail
x-text-area-inputtruetruefalse{ name: string, value: string }
x-text-area-changetruetruefalse{ name: string, value: string }
  • x-text-area-input — fires on every keystroke (mirrors native input event).
  • x-text-area-change — fires when the value is committed (mirrors native change event, e.g. on blur).

Shadow DOM Parts

Use ::part() to style internal elements from outside the component.

PartElementDescription
field<div>Outer flex container (column layout).
label<label>Label element. Hidden when label attribute is absent.
textarea-wrapper<div>Wrapper around the textarea.
textarea<textarea>The native textarea element.
hint<span>Hint text. Hidden when hint attribute is absent.
error<span>Error message. Hidden when error attribute is absent.

CSS Custom Properties

All properties are set on :host and can be overridden per-instance or globally.

PropertyDefault (light)Description
--x-text-area-label-color#374151Label text color.
--x-text-area-label-font-size0.875remLabel font size.
--x-text-area-bg#ffffffTextarea background color.
--x-text-area-color#111827Textarea text color.
--x-text-area-border1px solid #d1d5dbTextarea border.
--x-text-area-border-radius6pxCorner radius.
--x-text-area-padding0.5rem 0.75remInner padding.
--x-text-area-focus-ring-color#2563ebFocus ring and border color on focus.
--x-text-area-error-color#dc2626Border and text color in error state.
--x-text-area-hint-color#6b7280Hint text color.
--x-text-area-disabled-opacity0.45Opacity when disabled.
--x-text-area-min-height5remMinimum height of the textarea.
--x-text-area-font-size1remFont size of the textarea text.
--x-text-area-resizeverticalCSS resize property on the textarea.

Dark mode values are set automatically via @media (prefers-color-scheme: dark).

Accessibility

  • The <label> is associated with the <textarea> via for/id and aria-labelledby.
  • aria-required is set to "true" when the required attribute is present.
  • aria-invalid is set to "true" when the error attribute is non-empty.
  • aria-describedby dynamically includes hint and/or error element IDs.
  • The error <span> has role="alert" and aria-live="assertive" for screen reader announcements.
  • The hint <span> has aria-live="polite".

Form Integration

x-text-area is a form-associated custom element. It integrates natively with <form>:

  • Participates in form submission via FormData using the name attribute.
  • Responds to form reset — clears the value.
  • Disabled by the form when the containing <fieldset disabled> is present.
  • Constraint validation via ElementInternals (supports required, maxlength, custom error).

Usage Examples

Basic

<x-text-area
  name="bio"
  label="Biography"
  placeholder="Tell us about yourself"
  rows="5">
</x-text-area>

With hint and error

<x-text-area
  name="feedback"
  label="Feedback"
  hint="Be as specific as possible."
  error="Feedback is required."
  required>
</x-text-area>

With character limit

<x-text-area
  name="summary"
  label="Summary"
  maxlength="280"
  rows="4">
</x-text-area>

Non-resizable

<x-text-area name="notes" resize="none" rows="3"></x-text-area>

Listening to events

document.querySelector('x-text-area').addEventListener('x-text-area-input', (e) => {
  console.log('name:', e.detail.name, 'value:', e.detail.value);
});

Setting value programmatically

const ta = document.querySelector('x-text-area');
ta.value = 'Prepopulated content';

Custom styling

x-text-area {
  --x-text-area-border-radius: 12px;
  --x-text-area-focus-ring-color: #8b5cf6;
  --x-text-area-min-height: 8rem;
}

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close