Textarea
Introduction
Section titled “Introduction”Multi-line text entry. Textarea renders a native <textarea> with the same field chrome and constraint set as Text Input: label, required indicator, help text, validation message, and optional character counter. Validation runs in the shared validation engine, so messages are localized and identical in every browser. resize: 'auto' grows the control with its content.
- Multi-line entryA native textarea with label, required marker, help text, and validation message.
- Grows with contentAuto resize expands the field as text is added, up to an optional row limit.
- Length limitsMinimum and maximum length with an optional live character counter.
- Shared validationLocalized messages from the same engine as every other AbsoluteUI field.
Use it for
- Free text that may span several lines: comments, descriptions, messages, addresses.
- Long-form values with a length limit that users should see while typing.
- Fields that need consistent, localized validation messages across browsers.
Use something else for
- Single-line values such as names or email addresses: use Text Input.
- Formatted rich text: use Rich Text Editor.
- Numbers: use Number Input.
Anatomy
<div class="aui-field aui-textarea" data-aui-control> (consumer host) <label class="aui-field__label" for=textarea>Label<span class="aui-field__required" aria-hidden="true">*</span></label> <textarea class="aui-textarea__input" rows> <div class="aui-field__description"> (optional) <div class="aui-field__counter"> (showCounter) <div class="aui-field__error aui-validation-message"> (when shown)</div>Live example
Section titled “Live example”Use the bar above each frame to switch theme, density, direction, and locale.
Textarea in the Employee profile form showcase
Section titled “Textarea in the Employee profile form showcase”The part of the Employee profile form showcase that uses Textarea. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.
Showcase source
// Forms showcase: an employee profile form that uses every form control together,// with constraint validation, a cross-field rule, the error summary, reset, and live options.import { Button } from '@absoluteui/components/button';import { Checkbox } from '@absoluteui/components/checkbox';import { CheckboxGroup } from '@absoluteui/components/checkbox-group';import { Combobox } from '@absoluteui/components/combobox';import { Fieldset } from '@absoluteui/components/fieldset';import { Form, type FormSubmitDetail } from '@absoluteui/components/form';import { FormField } from '@absoluteui/components/form-field';import { MultiSelect } from '@absoluteui/components/multi-select';import { NumberInput } from '@absoluteui/components/number-input';import { RadioGroup } from '@absoluteui/components/radio-group';import { Select } from '@absoluteui/components/select';import { Slider } from '@absoluteui/components/slider';import { Switch } from '@absoluteui/components/switch';import { TextInput } from '@absoluteui/components/text-input';import { Textarea } from '@absoluteui/components/textarea';import { ValidationMessage } from '@absoluteui/components/validation-message';import { action, annotate, choice, createShowcase, hostIn, toggle } from './kit.js';
const sc = createShowcase({ title: 'Employee profile', description: 'Every form control in one form: required fields, formats, ranges, a cross-field rule, and an error summary on submit.',});
const form = document.createElement('form');form.className = 'sc-form';form.noValidate = true;sc.stage.append(form);
// Each fieldset declares its controls, so a component's focus view shows its own group.const fieldset = (legend: string, description?: string): HTMLFieldSetElement => { const fs = document.createElement('fieldset'); form.append(fs); Fieldset.enhance(fs, { legend, ...(description ? { description } : {}) }); return fs;};
const DEPARTMENTS = [ { value: 'eng', label: 'Engineering' }, { value: 'fin', label: 'Finance' }, { value: 'hr', label: 'People' }, { value: 'ops', label: 'Operations' }, { value: 'sales', label: 'Sales' },];const MANAGERS = ['Ada Kowalski', 'Bruno Silva', 'Chen Wei', 'Divya Nair', 'Emeka Obi', 'Farah Haddad', 'Grace Liu', 'Hiro Tanaka'].map((name) => ({ value: name.toLowerCase().replace(/\s+/g, '-'), label: name }));const SKILLS = ['Accessibility', 'Angular', 'Data analysis', 'Design systems', 'Finance', 'Negotiation', 'People management', 'TypeScript'].map((s) => ({ value: s.toLowerCase().replace(/\s+/g, '-'), label: s }));
// Personal details.const personal = annotate(fieldset('Personal details'), ['form', 'error-summary', 'fieldset', 'text-input', 'textarea', 'form-field']);const name = TextInput.create(hostIn(personal), { label: 'Full name', name: 'name', required: true, minLength: 2, autocomplete: 'name' });const email = TextInput.create(hostIn(personal), { label: 'Work email', name: 'email', type: 'email', required: true, autocomplete: 'email', description: 'Used for sign-in and notifications.' });const phone = TextInput.create(hostIn(personal), { label: 'Phone', name: 'phone', type: 'tel', inputMode: 'tel', pattern: '[+]?[0-9 ]{7,20}', description: 'Digits and spaces, with an optional leading +.' });const bio = Textarea.create(hostIn(personal), { label: 'About', name: 'bio', maxLength: 280, showCounter: true, rows: 3, resize: 'vertical' });
// A native control labelled and validated by Form Field.const badge = document.createElement('input');badge.name = 'badge';badge.inputMode = 'numeric';badge.pattern = '[0-9]{6}';FormField.create(hostIn(personal), { label: 'Badge number', control: badge, description: 'Six digits printed on your badge.' });
// Role.const role = annotate(fieldset('Role'), ['form', 'error-summary', 'validation-message', 'fieldset', 'select', 'combobox', 'radio-group', 'number-input', 'slider', 'multi-select']);const department = Select.create(hostIn(role), { label: 'Department', name: 'department', options: DEPARTMENTS, placeholder: 'Choose a department', required: true });const manager = Combobox.create(hostIn(role), { label: 'Manager', name: 'manager', options: MANAGERS, placeholder: 'Type a name', description: 'Search by first or last name.' });const type = RadioGroup.create(hostIn(role), { label: 'Employment type', name: 'type', orientation: 'horizontal', required: true, options: [{ value: 'full', label: 'Full time' }, { value: 'part', label: 'Part time' }, { value: 'contract', label: 'Contractor' }] });const salary = NumberInput.create(hostIn(role), { label: 'Annual salary', name: 'salary', min: 10000, max: 500000, step: 1000, format: { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 } });const hours = Slider.create(hostIn(role), { label: 'Weekly hours', name: 'hours', min: 8, max: 48, step: 1, largeStep: 4, value: 40, marks: [{ value: 20, label: '20' }, { value: 40, label: '40' }], showValue: true });const skills = MultiSelect.create(hostIn(role), { label: 'Skills', name: 'skills', options: SKILLS, maxSelected: 5, description: 'Up to five.' });
// Preferences.const prefs = annotate(fieldset('Preferences', 'You can change these later in settings.'), ['form', 'error-summary', 'fieldset', 'checkbox-group', 'switch', 'checkbox']);const benefits = CheckboxGroup.create(hostIn(prefs), { label: 'Benefits', name: 'benefits', orientation: 'horizontal', options: [{ value: 'health', label: 'Health' }, { value: 'pension', label: 'Pension' }, { value: 'transit', label: 'Transit pass' }, { value: 'gym', label: 'Gym' }] });const remote = Switch.create(hostIn(prefs), { label: 'Works remotely', name: 'remote' });const terms = Checkbox.create(hostIn(prefs), { label: 'I confirm these details are correct', name: 'terms', required: true });
// A standalone validation message for a rule that is not tied to one control.const actions = annotate(hostIn(form), ['form', 'error-summary', 'validation-message']);actions.className = 'sc-form__actions';const hint = ValidationMessage.create(hostIn(actions), { tone: 'info', message: 'Part-time employees work at most 32 hours per week.' });
const buttons = hostIn(actions);buttons.className = 'sc-form__buttons';const submit = Button.create({ text: 'Save profile', variant: 'primary', type: 'submit' }, document);const reset = Button.create({ text: 'Reset', variant: 'secondary', type: 'reset' }, document);buttons.append(submit.element, reset.element);
const formController = Form.create(form, { summaryTitle: 'Fix these fields to save the profile', rules: [ { fields: ['type', 'hours'], validate: (values) => (values.type === 'part' && Number(values.hours) > 32 ? 'Part-time employees work at most 32 hours per week.' : null), }, ],});
form.addEventListener('aui-submit', (e) => { const { values } = (e as CustomEvent<FormSubmitDetail>).detail; submit.setLoading(true); // A save takes a moment; the button stays busy and focusable meanwhile. setTimeout(() => { submit.setLoading(false); hint.update({ tone: 'success', message: `Saved the profile of ${typeof values.name === 'string' ? values.name : 'the employee'}.` }); }, 600);});form.addEventListener('aui-reset', () => { hint.update({ tone: 'info', message: 'Part-time employees work at most 32 hours per week.' });});
sc.listen(form, ['aui-submit', 'aui-invalid', 'aui-reset'], 'form');for (const [label, host] of [ ['name', name.host], ['email', email.host], ['department', department.host], ['manager', manager.host], ['type', type.host], ['salary', salary.host], ['hours', hours.host], ['skills', skills.host], ['benefits', benefits.host], ['remote', remote.host], ['terms', terms.host],] as const) { sc.listen(host, ['aui-change'], label);}
// Options.const all = [name, email, phone, bio, department, manager, type, salary, hours, skills, benefits, remote, terms];toggle(sc, 'Disabled', false, (disabled) => { for (const c of all) c.update({ disabled }); badge.disabled = disabled; submit.update({ disabled });});toggle(sc, 'Read-only', false, (readOnly) => { for (const c of [name, email, phone, bio, department, manager, salary, skills]) c.update({ readOnly }); badge.readOnly = readOnly;});choice( sc, 'Validate', [ { value: 'blur', label: 'When leaving a field' }, { value: 'input', label: 'While typing' }, { value: 'submit', label: 'On submit only' }, ], 'blur', (timing) => { for (const c of [name, email, phone, bio, department, type, salary, benefits, terms]) c.update({ validationTiming: timing }); },);action(sc, 'Fill sample data', () => { name.setValue('Ada Lovelace'); email.setValue('ada@example.com'); phone.setValue('+44 20 7946 0000'); bio.setValue('Writes the first programs and reviews every pull request.'); badge.value = '204816'; department.setValue('eng'); manager.setValue('chen-wei'); type.setValue('full'); salary.setValue(86000); hours.setValue(38); skills.setValue(['typescript', 'accessibility']); benefits.setValue(['health', 'pension']); remote.setChecked(true); terms.setChecked(true); sc.log('sample data filled');});action(sc, 'Submit empty', () => { formController.reset(); formController.submit();}, ['form', 'error-summary']);Required comments with a character counter
Section titled “Required comments with a character counter”import { Textarea } from '@absoluteui/components/textarea';
const host = document.createElement('div');document.body.append(host);const comments = Textarea.create(host, { label: 'Comments', name: 'comments', required: true, maxLength: 500, showCounter: true });host.addEventListener('aui-change', () => { host.dataset.valid = String(comments.validity.valid);});Grow with content between 2 and 8 rows
Section titled “Grow with content between 2 and 8 rows”import { Textarea } from '@absoluteui/components/textarea';
const host = document.createElement('div');document.body.append(host);Textarea.create(host, { label: 'Message', rows: 2, resize: 'auto', maxRows: 8 });Custom validation
Section titled “Custom validation”import { Textarea } from '@absoluteui/components/textarea';
const host = document.createElement('div');document.body.append(host);Textarea.create(host, { label: 'Bio', minLength: 20, validate: (value) => (/https?:\/\//.test(value) ? 'Links are not allowed in the bio.' : null),});Show messages on first input (Mode B)
Section titled “Show messages on first input (Mode B)”import { configureAbsoluteUI } from '@absoluteui/core';
configureAbsoluteUI({ components: { textarea: { validationTiming: 'input' } } });Install and start
Section titled “Install and start”npm install @absoluteui/components @absoluteui/core @absoluteui/themeRegistry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.
import { Textarea } from '@absoluteui/components/textarea';import '@absoluteui/components/textarea/style.css';First use
Section titled “First use”import { Textarea } from '@absoluteui/components/textarea';import '@absoluteui/components/textarea/style.css';
const host = document.querySelector<HTMLElement>('#feedback');if (host) { const feedback = Textarea.create(host, { label: 'Feedback', name: 'feedback', required: true, maxLength: 1000, showCounter: true, resize: 'auto', maxRows: 10 }); host.addEventListener('aui-change', () => { if (!feedback.validity.valid) feedback.reportValidity(); });}More usage
import { Textarea } from '@absoluteui/components/textarea';
const host = document.createElement('div');document.body.append(host);Textarea.create(host, { label: 'Message', rows: 2, resize: 'auto', maxRows: 8, maxLength: 500, showCounter: true });Using Angular? See Textarea for Angular.
API reference
Section titled “API reference”Factory
Section titled “Factory”Textarea.create(host: HTMLElement, options: TextareaOptions): TextareaGlobal configuration key: textarea (see Configuration).
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
label |
string |
Visible label and accessible name. Required. | |
hideLabel |
boolean |
false |
Visually hide the label; it remains the accessible name. |
value |
string |
"" |
Initial value; also the value restored by reset(). |
name |
string |
Form field name. | |
placeholder |
string |
Supplementary hint; never replaces the label. | |
description |
string |
Help text referenced by aria-describedby. | |
required |
boolean |
false |
Empty value is invalid; shows the required indicator. |
disabled |
boolean |
false |
Disables the textarea. |
readOnly |
boolean |
false |
Value is focusable and submitted but not editable. |
minLength |
number |
Minimum length in code points. | |
maxLength |
number |
Maximum length in code points (validated, not truncated). | |
showCounter |
boolean |
false |
Show remaining/over characters; requires maxLength. |
rows |
number |
3 |
Visible text rows, integer 1..100; the minimum height for resize ‘auto’. |
resize |
'none' | 'vertical' | 'auto' |
"vertical" |
Native vertical resize handle, fixed height, or grow with content. |
maxRows |
number |
Upper bound in rows for resize ‘auto’ (integer >= rows); content scrolls beyond it. | |
autocomplete |
string |
Native autocomplete token. | |
spellcheck |
boolean |
true |
Native spellcheck. |
validate |
(value: string) => string | null |
Consumer validation; return a message to mark the value invalid. | |
icons |
Partial<{ error: IconRef }> |
Icon slot overrides. | |
validationTiming |
'blur' | 'input' | 'submit' |
"blur" |
When validation messages first appear; afterwards they update live. Globally configurable. |
locale |
string |
"en-US" |
Message and number-formatting locale. Globally configurable. Inherited from common configuration. |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
host |
HTMLElement |
Consumer host; its children are owned by the component. |
textarea |
HTMLTextAreaElement |
The native textarea. |
value |
string |
Current value. |
name |
string | null |
Form field name. |
label |
string |
Label text. |
disabled |
boolean |
Disabled state. |
validity |
FieldValidity |
{ valid, error, message }; computed on every change. |
dirty |
boolean |
Value differs from the initial value. |
touched |
boolean |
Focus has left the control at least once. |
options |
Readonly<TextareaOptions> |
Current instance options. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
setValue(value: string): void |
Programmatic value (no events); clears an external custom error. |
update(options: Partial<TextareaOptions>): void |
Merge and apply options. |
reportValidity(): boolean |
Show messages now and return validity. |
setCustomError(message: string | null): void |
External error (server, cross-field rule); cleared when the user edits. |
getFormValue(): string |
Value for form serialization. |
focus(): void |
Focus the textarea. |
reset(): void |
Restore the initial value and clear dirty/touched/submitted state. |
destroy(): void |
Remove rendering, listeners, registration, and subscriptions. |
Events
Section titled “Events”| Event | Detail | Bubbles | Cancelable | Description |
|---|---|---|---|---|
aui-input |
{ value: string; validity: FieldValidity } |
Yes | No | User edited the value. |
aui-change |
{ value: string; validity: FieldValidity } |
Yes | No | User committed the value (native change, on blur). |
CSS classes
Section titled “CSS classes”All rules live in the aui.components cascade layer, so application styles override them without specificity battles.
| Class | Purpose |
|---|---|
aui-field aui-textarea |
Host. |
aui-textarea--invalid | --disabled |
State modifiers on the host. |
aui-textarea--resize-none | --auto | --auto-native |
Sizing modifiers on the host (–auto-native: field-sizing: content is used). |
aui-field__label | __required | __description | __counter | __error |
Shared field chrome. |
aui-textarea__input |
Native textarea; also the control boundary. |
Icon slots
Section titled “Icon slots”| Slot | Default icon |
|---|---|
error |
alert-circle |
Design tokens
Section titled “Design tokens”Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.
--aui-border-width | --aui-color-border | --aui-color-border-strong | --aui-color-disabled-bg | --aui-color-error-fg | --aui-color-focus-ring | --aui-color-surface | --aui-color-surface-sunken | --aui-color-text | --aui-color-text-disabled | --aui-color-text-muted | --aui-control-height-md | --aui-control-padding-x | --aui-duration-fast | --aui-easing-standard | --aui-focus-ring-width | --aui-font-family-sans | --aui-font-size-md | --aui-font-size-sm | --aui-font-weight-medium | --aui-icon-size-sm | --aui-line-height-normal | --aui-line-height-tight | --aui-radius-md | --aui-space-1 | --aui-space-2
TypeScript definitions
type TextareaResize = 'none' | 'vertical' | 'auto';type ValidationTiming = 'blur' | 'input' | 'submit';interface FieldValidity { readonly valid: boolean; readonly error: ValidationErrorCode | null; readonly message: string }interface TextareaValueDetail { value: string; validity: FieldValidity }Accessibility and performance
Section titled “Accessibility and performance”Accessibility
Section titled “Accessibility”Pattern: Native <textarea> with a <label for> association (HTML).
Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.
Keyboard
Section titled “Keyboard”| Key | Context | Action |
|---|---|---|
| Tab / Shift+Tab | Any | Moves focus to and from the textarea. |
| Enter | Textarea focused | Inserts a line break (native). |
| All editing keys | Textarea focused | Native text editing. |
| Element | Role |
|---|---|
| textarea | textbox (native, multi-line) |
| icons | none (aria-hidden=true) |
ARIA attributes
Section titled “ARIA attributes”| Attribute | Element | Value |
|---|---|---|
aria-describedby |
textarea | Help text, counter, and visible error message ids |
aria-invalid |
textarea | “true” only while an error message is shown |
The textarea shows the focus indicator (focus-ring-width outline in color-focus-ring, border color, and a 1px ring).
WCAG 2.2 success criteria addressed
Section titled “WCAG 2.2 success criteria addressed”Automated test results: Accessibility and compliance.
Notes and known caveats
Section titled “Notes and known caveats”- The required asterisk is aria-hidden; required state is conveyed by the native required attribute.
- Errors appear after the first blur by default so users are not interrupted while typing.
- The character count is announced through a polite live region only near or over the limit, 750 ms after typing stops.
- Auto-grow keeps the whole value visible up to maxRows, which helps users review what they wrote.
- Screen-reader announcement of the counter has not yet been manually verified with NVDA, JAWS, and VoiceOver.
Performance
Section titled “Performance”| Import cost | Minified | gzip | brotli | CSS brotli |
|---|---|---|---|---|
@absoluteui/components/textarea |
42.8 kB | 14.6 kB | 12.9 kB | 0.9 kB |
Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.
| Budget (enforced in CI) | Limit |
|---|---|
| Textarea.create, per instance (1,000 instances) | < 1 ms average in headless Chromium |
Tested scale: Target: 1,000 textareas on one page (performance test pending the e2e harness entry).
Three listeners per instance (input, change, focusout) and one configuration subscription. With native field-sizing there is no layout work in script; the fallback performs one layout read (scrollHeight) per input event. Budget: under 1 ms average per Textarea.create across 1,000 instances.
Measured run times: Performance.
Details
Section titled “Details”States
default, focus-visible, filled, disabled, read-only, required, invalid (message shown), over limit, auto-grow.
State transitions
| From | Trigger | To |
|---|---|---|
| pristine | user types | dirty; message shown only with validationTiming: 'input' |
| any | focus leaves the host | touched; messages shown (blur timing), after the pointer is released if focus left by a click |
| any | reportValidity() (for example on form submit) |
submitted; messages shown for every timing |
| invalid (custom error) | user edits | custom error cleared, validity recomputed |
| auto-grow | user types or the value is set | height follows content between rows and maxRows |
| any | reset() |
initial value; pristine, untouched |
Accessibility notes
- The required asterisk is
aria-hidden; the nativerequiredattribute conveys the state. - Errors appear after the first blur by default, then update live.
- The counter is announced through a polite live region only near or over the limit, 750 ms after typing stops.
- Auto-grow keeps the whole value visible up to
maxRows, so users can review what they wrote without scrolling. - Manual screen-reader verification is pending (see Known limitations).
Responsive behavior
Full width of its container. Height follows rows. With resize: 'vertical' users can drag the height; with 'auto' the control grows between rows and maxRows and then scrolls. Density tokens change font size and padding; the row bounds use lh units so they follow them.
Right-to-left
Logical properties throughout. The native resize handle follows the writing direction.
Theming
Colors come from role tokens only (light, dark, and high-contrast themes). In forced-colors mode, focus draws a Highlight outline.
Global configuration
configureAbsoluteUI({ components: { textarea: { validationTiming: 'input' } } });Changes apply to existing instances immediately.
Component configuration
Instance options override global and theme defaults. All options are dynamic.
Icons
icons.error (default alert-circle).
Security
All text uses textContent. Validation messages never include the entered value. Auto-grow sizing is written through the CSSOM (style.setProperty), never through a style attribute. CSP-safe (no inline styles or HTML sinks).
Data handling
No persistence, network access, or telemetry. The native textarea carries the value for form submission when name is set.
Supported data scale
1,000 textareas per page is the performance target. Values of any length; counters count code points.
Edge cases
- Pasting text longer than
maxLengthkeeps the text and shows the over-limit count and message. - A line break counts as one character.
maxRowswithoutresize: 'auto', or smaller thanrows, throwsTEXTAREA_OPTIONS.- Auto-grow on a textarea that is not connected (or is hidden) is measured on the next input event.
Errors
| Code | Category | Cause |
|---|---|---|
TEXTAREA_OPTIONS |
configuration | Missing label; invalid lengths, rows, resize, or maxRows; or showCounter without maxLength. |
Validation (validity.error) |
validation | value-missing, too-short, too-long, custom. |
A failed construction leaves no rendering, listeners, or subscriptions behind.
Known limitations
maxLengthis validated, not truncated.- Grapheme clusters such as flag emoji count as more than one character.
- Without native
field-sizingsupport, a container resize that rewraps text is applied on the next edit. - Only vertical resizing is offered.
- Screen-reader behavior of the counter has not yet been manually verified with NVDA, JAWS, and VoiceOver.
Unsupported scenarios
- HTML in the label, help text, or messages.
- Rich text, mentions, or syntax highlighting.
- Native
maxlengthtruncation.
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.