Skip to content

Textarea ​

An enhanced native <textarea>: auto height (capped or unlimited), character count, clearable, size tiers, variants and validation status.

Basic Usage ​

Basic usage

Rows & Resize ​

rows / resize

resize is passed through to the native resize value (none / both / horizontal / vertical), defaulting to none.

Auto Height ​

autosize

autosize enables auto height: the height grows with content, returns to the minimum height when empty, and shows a scrollbar when exceeding max-rows (default 6).

Autosize Bounds ​

autosize + min-rows / max-rows

min-rows (default 1) controls the minimum height, max-rows (default 6) caps the height and shows a scrollbar. The legacy attribute auto-height is kept for compatibility.

Unlimited Auto Height ​

autosize + max-rows=0

max-rows="0" explicitly disables the cap: the height grows indefinitely with content and never shows a scrollbar (long-form writing, log pasting). Omitting max-rows keeps the default 6-row cap — unlimited growth must be set explicitly.

auto-height Compatibility Alias ​

auto-height

auto-height is a compatibility alias for autosize with identical behavior: grows with content, returns to the minimum row height when empty, and shows a scrollbar beyond max-rows (default 6). Setting either one enables auto height.

Size Tiers ​

size

size="small | medium | large" (default medium): font size, vertical padding and minimum height scale with the tier, aligned with the global control size tokens.

Variants ​

variant

variant="outlined | filled | borderless" (default outlined). filled uses a gray background without a border, showing the border on focus; borderless has a transparent background and no border, keeping only the focus ring.

Validation Status ​

status

status="error | warning | success": the border and focus ring change color with the validation result; error also sets aria-invalid on the inner textarea (perceivable by screen readers). When linked with oas-form-item validation, form-item writes aria-invalid on the host, visually identical to error.

Character Count ​

maxlength + show-count

show-count displays a counter at the bottom-right outside the box: n/max when maxlength is set (majority convention, turns red when over; maxlength is passed through to the native attribute, truncating at the input layer), or just the current length when unset. The counter carries aria-live="polite" so screen readers announce count changes.

Clearable ​

clearable

This comment can be cleared and rewritten in one click.

clearable shows a clear button at the top-right corner when there is a value (hidden when disabled / readonly): clicking clears the content, emits the oas-clear event, and returns focus to the textarea; under autosize the height shrinks back accordingly.

label Accessible Name ​

label

label is written to the inner aria-label as the accessible name, with fallback order: label > placeholder > built-in default text. For a visible form label use the oas-form-item label channel (label layout belongs to form-item).

Native Attribute Passthrough ​

Native attribute passthrough

Whitelisted attributes are passed through to the inner native <textarea>: name / autofocus / minlength / required / spellcheck / autocomplete / wrap. With native oas-form submission, name participates in form data and required / minlength in native constraint validation; wrap="hard" requires cols to submit hard line breaks.

Disabled & Readonly ​

disabled / readonly

Events ​

Input and focus events

  • oas-input: on every keystroke, detail: { value }
  • oas-focus / oas-blur: on focus / blur, detail: { value }
  • oas-change: emitted on blur only when the value changed since focus (commit semantics), detail: { value }

Methods ​

focus() / blur() / select()

select()focus()blur()

focus(options?) / blur() / select() all delegate to the inner native textarea.

Programmatic read/write of the current value goes through the public value property (like the native textarea.value): el.value reads the current text while the inner textarea is present, otherwise the value attribute snapshot; el.value = x writes the controlled value attribute and immediately syncs the inner control without dispatching events.

API ​

oas-textarea ​

Attributes ​

AttributeDescriptionTypeDefault
auto-heightLegacy name (alias of autosize)boolean—
autocompletePassed through to the inner native textarea——
autofocusAutofocus (native passthrough)——
autosizeAuto heightboolean—
clearableShow a clear button (one-click clear; fires oas-clear + oas-input)boolean—
disabledDisabledboolean—
labelAccessible name (aria-label channel; falls back to placeholder → locale)——
max-rowsMaximum rows in autosizestring—
maxlengthMaximum length (native passthrough; pair with show-count)string—
min-rowsMinimum rows in autosizestring1
minlengthMinimum length (native passthrough)——
nameForm field name (native passthrough)——
placeholderPlaceholder textstring—
readonlyReadonlyboolean—
requiredRequired marker (native passthrough)boolean—
resizeResize behaviorstring—
rowsNumber of rowsstring3
show-countShow character count (bottom-right n/max; turns red over limit; aria-live announced)boolean—
sizeSize preset small / medium (default) / large——
spellcheckSpellcheck (native passthrough)——
statusValidation status: error / warning / success; error mirrors aria-invalid on the inner textareastring—
valueValue (controlled)string—
variantVariant: outlined (default) / filled / borderlessstringoutlined
wrapWrap strategy (native passthrough: soft/hard)——

Property (JS property; see each row for attribute reflection) ​

PropertyDescriptionTypeDefault
valueCurrent value: the inner textarea text (el.value reads; el.value = x writes the controlled value and syncs, no event)string—

Events ​

EventDescription
oas-blurFires on blur, detail: { value }
oas-changeNative change semantics: fires on blur when the value changed, detail: { value }
oas-clearFires when the clear button is clicked (oas-input also fires), detail: { originalEvent: new MouseEvent('click') }
oas-focusFires on focus, detail: { value }
oas-inputWhile typing, detail: { value }

Released under the MIT OR Apache-2.0 License.