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.

| 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.
<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>
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-react';
export default function TextareaBasics() {
return (
<AegovFormField>
<AegovLabel>
Describe your enquiry
<span className="text-aered-600" aria-hidden="true">*</span>
<span className="sr-only">(required)</span>
</AegovLabel>
<AegovTextarea
fieldId="textarea-basics"
name="enquiry"
placeholder="Tell us how we can help..."
rows={5}
isRequired
/>
</AegovFormField>
);
}
<template>
<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>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-angular';
@Component({
selector: 'app-textarea-basics',
imports: [AegovFormField, AegovLabel, AegovTextarea],
template: `
<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" [isRequired]="true"></aegov-textarea>
</aegov-form-field>
`,
})
export class TextareaBasicsComponent {}
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.
<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>
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-react';
export default function TextareaResize() {
return (
<>
<AegovFormField>
<AegovLabel>Vertical resize (default): drag the bottom-right handle</AegovLabel>
<AegovTextarea fieldId="textarea-resize-vertical" resize="vertical" />
</AegovFormField>
<AegovFormField>
<AegovLabel>No resize: fixed size</AegovLabel>
<AegovTextarea fieldId="textarea-resize-none" resize="none" />
</AegovFormField>
<AegovFormField>
<AegovLabel>Auto: grows as you type</AegovLabel>
<AegovTextarea fieldId="textarea-resize-auto" resize="auto" rows={2} />
</AegovFormField>
</>
);
}
<template>
<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>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-angular';
@Component({
selector: 'app-textarea-resize',
imports: [AegovFormField, AegovLabel, AegovTextarea],
template: `
<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>
`,
})
export class TextareaResizeComponent {}
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.
<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>
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-react';
export default function TextareaSizes() {
return (
<>
<AegovFormField>
<AegovLabel>Small (sm)</AegovLabel>
<AegovTextarea fieldId="textarea-size-sm" size="sm" rows={3} />
</AegovFormField>
<AegovFormField>
<AegovLabel>Base (default)</AegovLabel>
<AegovTextarea fieldId="textarea-size-base" size="base" rows={3} />
</AegovFormField>
<AegovFormField>
<AegovLabel>Large (lg)</AegovLabel>
<AegovTextarea fieldId="textarea-size-lg" size="lg" rows={3} />
</AegovFormField>
</>
);
}
<template>
<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>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-angular';
@Component({
selector: 'app-textarea-sizes',
imports: [AegovFormField, AegovLabel, AegovTextarea],
template: `
<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>
`,
})
export class TextareaSizesComponent {}
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
<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>
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-react';
export default function TextareaVariants() {
return (
<>
<AegovFormField>
<AegovLabel>Primary</AegovLabel>
<AegovTextarea fieldId="textarea-variant-primary" variant="primary" rows={3} />
</AegovFormField>
<AegovFormField>
<AegovLabel>Secondary</AegovLabel>
<AegovTextarea fieldId="textarea-variant-secondary" variant="secondary" rows={3} />
</AegovFormField>
<AegovFormField>
<AegovLabel>Neutral-max</AegovLabel>
<AegovTextarea fieldId="textarea-variant-neutral-max" variant="neutral-max" rows={3} />
</AegovFormField>
<AegovFormField>
<AegovLabel>Neutral-min</AegovLabel>
<AegovTextarea fieldId="textarea-variant-neutral-min" variant="neutral-min" rows={3} />
</AegovFormField>
</>
);
}
<template>
<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>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-angular';
@Component({
selector: 'app-textarea-variants',
imports: [AegovFormField, AegovLabel, AegovTextarea],
template: `
<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>
`,
})
export class TextareaVariantsComponent {}
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.
<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>
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-react';
export default function TextareaCounter() {
return (
<AegovFormField>
<AegovLabel>
Reason for appeal
<span className="text-aered-600" aria-hidden="true">*</span>
<span className="sr-only">(required)</span>
</AegovLabel>
<AegovTextarea
fieldId="textarea-counter"
name="appeal-reason"
maxlength={500}
rows={6}
placeholder="Briefly describe your reason for appealing this decision..."
isRequired
/>
<span slot="hint">Provide as much detail as possible. Up to 500 characters.</span>
</AegovFormField>
);
}
<template>
<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>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-angular';
@Component({
selector: 'app-textarea-counter',
imports: [AegovFormField, AegovLabel, AegovTextarea],
template: `
<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..." [isRequired]="true"></aegov-textarea>
<span slot="hint">Provide as much detail as possible. Up to 500 characters.</span>
</aegov-form-field>
`,
})
export class TextareaCounterComponent {}
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.
<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>
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-react';
export default function TextareaStates() {
return (
<>
<AegovFormField>
<AegovLabel>Additional details</AegovLabel>
<AegovTextarea fieldId="textarea-disabled" isDisabled rows={3} value="This field is locked while the application is under review." />
</AegovFormField>
<AegovFormField>
<AegovLabel>Approval note</AegovLabel>
<AegovTextarea fieldId="textarea-readonly" isReadonly rows={4} value="Approved by the Ministry of Interior on 14 February 2026. Reference: APP-2026-008421." />
</AegovFormField>
<AegovTextarea
fieldId="textarea-copyable"
isReadonly
isCopyable
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."
/>
</>
);
}
<template>
<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>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-angular';
@Component({
selector: 'app-textarea-states',
imports: [AegovFormField, AegovLabel, AegovTextarea],
template: `
<aegov-form-field>
<aegov-label>Additional details</aegov-label>
<aegov-textarea field-id="textarea-disabled" [isDisabled]="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" [isReadonly]="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" [isReadonly]="true" [isCopyable]="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>
`,
})
export class TextareaStatesComponent {}
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.)
<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>
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-react';
export default function TextareaInvalid() {
return (
<AegovFormField isInvalid errorMessage="This field is required to submit the report.">
<AegovLabel>Describe the incident</AegovLabel>
<AegovTextarea fieldId="textarea-invalid" rows={4} />
</AegovFormField>
);
}
<template>
<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>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-angular';
@Component({
selector: 'app-textarea-invalid',
imports: [AegovFormField, AegovLabel, AegovTextarea],
template: `
<aegov-form-field [isInvalid]="true" errorMessage="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>
`,
})
export class TextareaInvalidComponent {}
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.
<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>
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-react';
export default function RtlTextarea() {
return (
<div dir="rtl">
<AegovFormField>
<AegovLabel>
سبب التظلم
<span className="text-aered-600" aria-hidden="true">*</span>
<span className="sr-only">(مطلوب)</span>
</AegovLabel>
<AegovTextarea
fieldId="textarea-rtl"
maxlength={500}
rows={6}
placeholder="اشرح بإيجاز سبب تقديمك للتظلم على هذا القرار..."
isRequired
/>
<span slot="hint">يرجى تقديم أكبر قدر ممكن من التفاصيل. حتى 500 حرف.</span>
</AegovFormField>
</div>
);
}
<template>
<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>
</template>
import { Component } from '@angular/core';
import { AegovFormField, AegovLabel, AegovTextarea } from '@aegov/designsystem-angular';
@Component({
selector: 'app-rtl-textarea',
imports: [AegovFormField, AegovLabel, AegovTextarea],
template: `
<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="اشرح بإيجاز سبب تقديمك للتظلم على هذا القرار..." [isRequired]="true"></aegov-textarea>
<span slot="hint">يرجى تقديم أكبر قدر ممكن من التفاصيل. حتى 500 حرف.</span>
</aegov-form-field>
</div>
`,
})
export class RtlTextareaComponent {}
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
| Attribute | Description | Type | Default |
|---|---|---|---|
| DOM |
| auto-generated |
| Form field name. Reflected on the host so |
| (none) |
| Current value — mutable, kept in sync internally on every |
|
|
| Placeholder text shown when empty. |
| (none) |
| Size token — affects font size and padding only, never the visible row count. Accepts a responsive breakpoint string, e.g. |
|
|
| Colour family for the idle ring, value text, and hover accent. |
|
|
| Resize-handle behaviour. |
|
|
| Maximum character count. Setting this applies the native |
| (none) |
| Shows a copy-to-clipboard button. Only takes effect when |
|
|
| Disables the textarea. |
|
|
| Marks the textarea read-only — still focusable and selectable, but not editable. |
|
|
| Marks the field as required (sets the native |
|
|
| Visual + a11y invalid state. |
|
|
| Inline error message shown when |
|
|
| Helper text shown below the field. It stays visible while an error shows (below the error message), and both describe the field. Use the |
|
|
| Additional CSS classes applied to the native |
| (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
| Event | Description | Detail |
|---|---|---|
| Fires on every keystroke. Use for live validation or a custom counter. |
|
| Fires when the value commits — the native |
|
| Fires when the textarea gains focus. |
|
| Fires when the textarea loses focus. |
|
| Unified validation event. See §2.3. |
|
Methods
| Method | Description |
|---|---|
| Imperatively re-runs validation and emits |
| Mirrors |
Slots
| Slot | Description |
|---|---|
| Rich markup for the hint, in place of the plain-text |
| Rich markup for the error message, in place of the plain-text |
Pass-through attributes
| Attribute | Notes |
|---|---|
| Forwarded automatically, except |
| Forwarded — sets the native initial visible height/width. |
| All forwarded onto the native |
| Not forwarded. Use |
| Applied to the host element — stays host-only. Use |
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-labelinsideaegov-form-field, anaegov-label for="…"pointing at the host'sidorfield-id, a native<label for="…">pointing at the host'sid, andaria-label/aria-labelledbyset on the host. - An
aria-describedbyyou 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-requiredsets the nativerequiredattribute, exposing the requirement to assistive technology automatically.- Setting
maxlengthapplies the real nativemaxlengthattribute (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>—Tabmoves to it right after the textarea — with a bilingualaria-label("Copy to clipboard" / "نسخ إلى الحافظة"). The button keeps its name after use; a visually hiddenrole="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, orvalidate('submit')has run, so a validation message present at initial load isn't announced as an interruption. - The
hint/error-messageprops (or thehint/errorslots placed insideaegov-textarea) are linked to the textarea's description automatically, and the hint stays visible while an error shows. When the textarea is wrapped inaegov-form-field, an element in the form field's ownhintslot 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-labelinsideaegov-form-fieldis the preferred pattern. For a standalone textarea with no visible label, setaria-labelon the host directly. - If the textarea collects the user's own details (for example a postal address), set the matching
autocompletevalue such asautocomplete="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, callvalidate('submit')on each field and setis-invalidanderror-messagefrom the result, so every error is shown, announced and stays on screen.
Additional notes
sizeaccepts a responsive breakpoint string, the same convention used by Badge, Banner, and Checkbox (e.g.size="sm md:base").is-copyablesilently has no effect unlessis-readonlyis also set — there's no copy button on an editable field, by design.- The character counter only ever shows an "over limit" state when
valueis set to something longer thanmaxlengthprogrammatically — ordinary typing can never exceed it, since the nativemaxlengthattribute 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. |