Docs

Main site

Installation Browser support Extend config MCP server
Validation Page speed testing Responsive design
Accordion Aspect Ratio Avatar Badge Banner Bento Grid Blockquote Breadcrumbs Button Callout Card Drawer Dropdown Link Modal Navbar Navblock Pagination Popover Progress Separator Tabs Timeline Toast Tooltip
Checkbox Datepicker File upload Form field Input Label OTP Radio Range Select Textarea Toggle
Header Footer
Accordion Auth Checkbox & Radio Content Drawers Features Modals Statistics & Metrics Teams Dropdowns
Address Contact number Currency symbol Date Emirates ID Name
Close
Home Documentation Components Textarea

Textarea

A Textarea collects multi-line text — feedback, addresses, complaint descriptions, justifications, or any free-form content that will not fit on a single line. "aegov-textarea" wraps a real native "textarea" so spell-check, autofill, and assistive technology all keep working, while layering on design-system sizing, resize control, a character counter, and copy-to-clipboard for read-only content.

input Interactive
Status
Active
Introduced
4.0.x
View source code

Anatomy

aegov-textarea renders a real native <textarea>, optionally wrapped alongside a copy button (when read-only and copyable) and a character counter (when maxlength is set), with hint and error regions as siblings.

Image showing anatomy of a textarea

Item Name Description
1 Control The native <textarea> element
2 Copy button (optional) Shown only when is-readonly and is-copyable are both set
3 Character counter (optional) Shown when maxlength is set
4 Hint / error message Supporting helper text; once is-invalid is set, the error message appears above it and the hint stays visible

Basics

Use aegov-textarea directly when you only need the field, or pair it with aegov-form-field and aegov-label to wire up a label, helper text, and validation together. aegov-label has no is-required property of its own — a required marker is content you author yourself (see the Label component's own docs for the fully accessible pattern); the real, programmatic requirement is set with is-required on the textarea itself.

Describe your enquiry (required)
<aegov-form-field>
  <aegov-label>
    Describe your enquiry
    <span class="text-aered-600" aria-hidden="true">*</span>
    <span class="sr-only">(required)</span>
  </aegov-label>
  <aegov-textarea field-id="textarea-basics" name="enquiry" placeholder="Tell us how we can help..." rows="5" is-required="true"></aegov-textarea>
</aegov-form-field>

Resize behaviour

resize controls whether and how the user can drag the resize handle: vertical (default), horizontal, both, none, or auto — which removes the handle entirely and instead grows the field to fit its content as the user types.

Vertical resize (default): drag the bottom-right handle No resize: fixed size Auto: grows as you type
<aegov-form-field>
  <aegov-label>Vertical resize (default): drag the bottom-right handle</aegov-label>
  <aegov-textarea field-id="textarea-resize-vertical" resize="vertical"></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
  <aegov-label>No resize: fixed size</aegov-label>
  <aegov-textarea field-id="textarea-resize-none" resize="none"></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
  <aegov-label>Auto: grows as you type</aegov-label>
  <aegov-textarea field-id="textarea-resize-auto" resize="auto" rows="2"></aegov-textarea>
</aegov-form-field>

Sizes

size accepts five tokens, from xs up to xl. It scales the font size and padding only — never the visible row count, which is set independently via the native rows attribute.

Small (sm) Base (default) Large (lg)
<aegov-form-field>
  <aegov-label>Small (sm)</aegov-label>
  <aegov-textarea field-id="textarea-size-sm" size="sm" rows="3"></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
  <aegov-label>Base (default)</aegov-label>
  <aegov-textarea field-id="textarea-size-base" size="base" rows="3"></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
  <aegov-label>Large (lg)</aegov-label>
  <aegov-textarea field-id="textarea-size-lg" size="lg" rows="3"></aegov-textarea>
</aegov-form-field>

Variant

variant selects the colour family for the idle ring, the value text, and the hover accent. The focus ring and error border stay constant regardless of variant.

Variant Idle ring Value text
primary primary-400 primary-900
secondary secondary-400 secondary-900
neutral-max aeblack-400 aeblack-900
neutral-min aeblack-200 aeblack-900

Variant example

Primary Secondary Neutral-max Neutral-min
<aegov-form-field>
  <aegov-label>Primary</aegov-label>
  <aegov-textarea field-id="textarea-variant-primary" variant="primary" rows="3"></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
  <aegov-label>Secondary</aegov-label>
  <aegov-textarea field-id="textarea-variant-secondary" variant="secondary" rows="3"></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
  <aegov-label>Neutral-max</aegov-label>
  <aegov-textarea field-id="textarea-variant-neutral-max" variant="neutral-max" rows="3"></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
  <aegov-label>Neutral-min</aegov-label>
  <aegov-textarea field-id="textarea-variant-neutral-min" variant="neutral-min" rows="3"></aegov-textarea>
</aegov-form-field>

Character counter

Set maxlength to an integer to enable both the native character limit and a live counter rendered below the field. Screen readers hear the remaining count in words as part of the field's description, and once typing pauses for about a second a polite status announces it. The counter switches to an over-limit style if the count ever exceeds the limit — which can only happen if value is set programmatically, since ordinary typing is capped by the native maxlength.

Reason for appeal (required) Provide as much detail as possible. Up to 500 characters.
<aegov-form-field>
  <aegov-label>
    Reason for appeal
    <span class="text-aered-600" aria-hidden="true">*</span>
    <span class="sr-only">(required)</span>
  </aegov-label>
  <aegov-textarea field-id="textarea-counter" name="appeal-reason" maxlength="500" rows="6" placeholder="Briefly describe your reason for appealing this decision..." is-required="true"></aegov-textarea>
  <span slot="hint">Provide as much detail as possible. Up to 500 characters.</span>
</aegov-form-field>

States

A textarea can be disabled, read-only, or read-only with a copy button. is-copyable only takes effect when is-readonly is also set — useful for system-generated decisions, official correspondence, or audit logs a user may want to copy without being able to edit.

Additional details Approval note Message to applicant
<aegov-form-field>
  <aegov-label>Additional details</aegov-label>
  <aegov-textarea field-id="textarea-disabled" is-disabled="true" rows="3" value="This field is locked while the application is under review."></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
  <aegov-label>Approval note</aegov-label>
  <aegov-textarea field-id="textarea-readonly" is-readonly="true" rows="4" value="Approved by the Ministry of Interior on 14 February 2026. Reference: APP-2026-008421."></aegov-textarea>
</aegov-form-field>
<aegov-form-field>
  <aegov-label>Message to applicant</aegov-label>
  <aegov-textarea field-id="textarea-copyable" is-readonly="true" is-copyable="true" rows="5" value="Dear applicant, your residency permit application has been approved. Please collect your card from the Ministry of Interior office in Abu Dhabi within 30 days."></aegov-textarea>
</aegov-form-field>

Invalid (error state)

Wrap the field in aegov-form-field and set is-invalid="true" together with error-message there — the form field cascades both is-invalid and the error text down to the textarea, which renders the actual error region and wires it up via aria-describedby. (The error slot is for rich markup on aegov-textarea itself; aegov-form-field has no slot of its own for it, so an error <span slot="error"> placed as a sibling under the form field would not render — use the error-message prop at the form-field level instead.)

Describe the incident
<aegov-form-field is-invalid="true" error-message="This field is required to submit the report.">
  <aegov-label>Describe the incident</aegov-label>
  <aegov-textarea field-id="textarea-invalid" rows="4"></aegov-textarea>
</aegov-form-field>

RTL support

The textarea uses CSS logical properties throughout. When the document or any ancestor is dir="rtl", padding flips, the resize handle follows the browser's native placement, the copy button moves to the bottom-left, and the character counter aligns to the end. No extra configuration is needed.

سبب التظلم (مطلوب) يرجى تقديم أكبر قدر ممكن من التفاصيل. حتى 500 حرف.
<div dir="rtl">
  <aegov-form-field>
    <aegov-label>
      سبب التظلم
      <span class="text-aered-600" aria-hidden="true">*</span>
      <span class="sr-only">(مطلوب)</span>
    </aegov-label>
    <aegov-textarea field-id="textarea-rtl" maxlength="500" rows="6" placeholder="اشرح بإيجاز سبب تقديمك للتظلم على هذا القرار..." is-required="true"></aegov-textarea>
    <span slot="hint">يرجى تقديم أكبر قدر ممكن من التفاصيل. حتى 500 حرف.</span>
  </aegov-form-field>
</div>

Usage

Here is the recommended usage of a textarea on any website or application. These are recommended usage guides, however the developer must use the best practices of web and application development to accurately use this component.

Set a maxlength whenever the destination has a real limit
A silent server-side truncation after submission is a far worse experience than a visible, live counter that tells the user the limit as they type.

Use resize="auto" for short, conversational fields; keep manual resize="vertical" for longer-form content
A comment or short-reason field feels more natural when it grows with the user's input; a multi-paragraph field benefits from a fixed starting size the user can deliberately expand.

Do not set is-copyable on an editable field expecting it to do anything
The copy button only ever renders when the field is also is-readonly — pairing is-copyable with an editable textarea silently produces no button at all.

API reference

The following are the properties and references of a textarea

aegov-textarea default properties

AttributeDescriptionTypeDefault

field-id

DOM id reflected on the inner native <textarea>. Auto-generated if omitted.

string

auto-generated

name

Form field name. Reflected on the host so ElementInternals can read it for native form submission.

string

(none)

value

Current value — mutable, kept in sync internally on every input/change. Setting it programmatically also re-triggers resize="auto"'s auto-grow, not just user typing.

string

''

placeholder

Placeholder text shown when empty.

string

(none)

size

Size token — affects font size and padding only, never the visible row count. Accepts a responsive breakpoint string, e.g. "sm md:base".

xs | sm | base | lg | xl

base

variant

Colour family for the idle ring, value text, and hover accent.

primary | secondary | neutral-max | neutral-min

primary

resize

Resize-handle behaviour. auto removes the manual resize handle entirely and instead grows the field to fit its content as the user types (or as value is set programmatically).

none | vertical | horizontal | both | auto

vertical

maxlength

Maximum character count. Setting this applies the native maxlength attribute (real, browser-enforced typing limit) and renders a live character counter below the field.

number

(none)

is-copyable

Shows a copy-to-clipboard button. Only takes effect when is-readonly is also true — it has no effect on an editable field.

boolean

false

is-disabled

Disables the textarea.

boolean

false

is-readonly

Marks the textarea read-only — still focusable and selectable, but not editable.

boolean

false

is-required

Marks the field as required (sets the native required attribute).

boolean

false

is-invalid

Visual + a11y invalid state.

boolean

false

error-message

Inline error message shown when is-invalid is set. Use the error slot for rich markup instead.

string

''

hint

Helper text shown below the field. It stays visible while an error shows (below the error message), and both describe the field. Use the hint slot instead for rich markup.

string

''

extra-class

Additional CSS classes applied to the native <textarea> itself (not the host).

string

(none)

This component renders inside a real shadow DOM, so extra-class only applies margin/padding (spacing) utilities — e.g. mt-4, md:px-6. Colour, border, typography, and every other visual utility are silently ignored: this is an isolated component whose internal styles can't be overridden, keeping it visually consistent wherever it's used.

Events

EventDescriptionDetail

aegovTextareaValue

Fires on every keystroke. Use for live validation or a custom counter.

{ value: string; event: Event }

aegovTextareaChange

Fires when the value commits — the native change event, typically on blur.

{ value: string; event: Event }

aegovTextareaFocus

Fires when the textarea gains focus.

FocusEvent

aegovTextareaBlur

Fires when the textarea loses focus.

FocusEvent

aegovValidate

Unified validation event. See §2.3.

AegovValidationDetail<string>

Methods

MethodDescription

validate(trigger?)

Imperatively re-runs validation and emits aegovValidate. Returns Promise<{ valid, message, validity }>.

setCustomValidity(message)

Mirrors HTMLTextAreaElement.setCustomValidity(). An empty string clears the custom error.

Slots

SlotDescription

hint

Rich markup for the hint, in place of the plain-text hint prop.

error

Rich markup for the error message, in place of the plain-text error-message prop.

Pass-through attributes

AttributeNotes

aria-*, data-*

Forwarded automatically, except aria-invalid (owned internally). Your aria-describedby is kept and combined with the counter/hint/error ids.

rows, cols

Forwarded — sets the native initial visible height/width.

minlength, wrap, autocomplete, autofocus, spellcheck, enterkeyhint, title, tabindex, form

All forwarded onto the native <textarea>.

id

Not forwarded. Use field-id to control the real inner id.

class, style

Applied to the host element — stays host-only. Use extra-class to add classes to the inner <textarea> itself.

Notes

The following notes are applicable of this component.

Built-in accessibility

  • Renders a real native <textarea>, so keyboard editing, selection, autofill, spellcheck, and assistive-technology behaviour all come for free.
  • The label reaches the native <textarea> inside the shadow DOM. ID references can't cross that boundary on their own, so the component resolves each naming source to text and gives it to the inner textarea: aegov-label inside aegov-form-field, an aegov-label for="…" pointing at the host's id or field-id, a native <label for="…"> pointing at the host's id, and aria-label / aria-labelledby set on the host.
  • An aria-describedby you set on the host is handled the same way: the referenced text becomes part of the textarea's description, read before the component's own counter, error and hint.
  • is-required sets the native required attribute, exposing the requirement to assistive technology automatically.
  • Setting maxlength applies the real native maxlength attribute (a genuine, browser-enforced typing limit, not just a visual cue) alongside the live counter. The visible "11 / 20" count is hidden from assistive technology; instead the field's description includes the remaining count in words ("9 characters remaining"), and a polite status announces it about a second after typing pauses, rather than on every keystroke.
  • The copy button (when is-copyable + is-readonly) is a real, keyboard-reachable <button> — Tab moves to it right after the textarea — with a bilingual aria-label ("Copy to clipboard" / "نسخ إلى الحافظة"). The button keeps its name after use; a visually hidden role="status" region announces "Copied" / "تم النسخ" instead. No developer translation is needed.
  • The error region only takes role="alert" after the user has blurred the field at least once, the form has reported it invalid, or validate('submit') has run, so a validation message present at initial load isn't announced as an interruption.
  • The hint / error-message props (or the hint / error slots placed inside aegov-textarea) are linked to the textarea's description automatically, and the hint stays visible while an error shows. When the textarea is wrapped in aegov-form-field, an element in the form field's own hint slot is linked too; other text placed beside the textarea is not.

Developer responsibility

The following is required for a developer to add additionally or pay attention to regarding this component.

  • Always provide a visible label — aegov-label inside aegov-form-field is the preferred pattern. For a standalone textarea with no visible label, set aria-label on the host directly.
  • If the textarea collects the user's own details (for example a postal address), set the matching autocomplete value such as autocomplete="street-address" so the browser can fill it in (WCAG 1.3.5 Identify Input Purpose). The attribute is passed through to the native textarea.
  • Pick a sensible maxlength: too low frustrates users mid-sentence, too high makes the counter meaningless. 500–1000 characters suits most feedback-style fields.
  • Confirm a copyable field's content is genuinely safe to land in a user's clipboard history before enabling is-copyable.
  • Handle form submission yourself. When the browser blocks a submit (for example a required field is empty), it only shows its own temporary bubble, in the browser's language: the field gets no error text on the page and no aria-invalid. Use the whole-form validation pattern: on submit, call validate('submit') on each field and set is-invalid and error-message from the result, so every error is shown, announced and stays on screen.

Additional notes

  • size accepts a responsive breakpoint string, the same convention used by Badge, Banner, and Checkbox (e.g. size="sm md:base").
  • is-copyable silently has no effect unless is-readonly is also set — there's no copy button on an editable field, by design.
  • The character counter only ever shows an "over limit" state when value is set to something longer than maxlength programmatically — ordinary typing can never exceed it, since the native maxlength attribute blocks further input at the browser level.

Keyboard support

Key Function
Tab Moves focus into the textarea. When a copy button is present, one more Tab reaches it.
Shift + Tab Moves focus to the previous focusable element.
Enter Inserts a new line inside the textarea — never submits an enclosing form.
Enter / Space (on the copy button) Copies the textarea's value to the clipboard.
Standard text-editing shortcuts All native browser behaviour applies — selection, cursor movement, cut/copy/paste.