Textarea
On this page
Labeling
Every <rh-textarea> must have an accessible name. Use one of the following approaches:
-
External
<label>element (recommended)- associate a
<label>with the textarea usingforandid. The component wires the label to the inner textarea viaariaLabelledByElements. See the default demo for an example.
- associate a
-
accessible-labelattribute: use when no visible label is present.
<rh-textarea accessible-label="Additional comments"></rh-textarea>
Users may also add an aria-label or aria-labelledby attribute on the host. aria-label overrides all other label sources; aria-labelledby takes priority over associated <label> elements and accessible-label.
Disabled vs. readonly
Both disabled and readonly prevent editing, but they differ in important ways:
- Disabled uses
aria-disabled(not nativedisabled) so the textarea remains focusable for assistive technology users. Disabled textareas are excluded from form submission. The element receivespointer-events: noneand muted visual styling. - Readonly prevents editing but keeps the value submittable. The textarea is fully focusable and interactive for text selection.
ARIA attributes
Always set ARIA attributes (e.g. aria-invalid, aria-label, aria-labelledby) on the <rh-textarea> host element. The component is a form-associated custom element, so the browser forwards host ARIA attributes to assistive technologies via ElementInternals.
Validation and error state
The state attribute (danger, warning, success) controls visual feedback only and does not set aria-invalid. When you have a validation error, set both so sighted and screen reader users get the same information:
state="danger"+help-text="..."for the visual cuearia-invalid="true"on the host for assistive tech
This keeps a single source of truth for validity in your code. For implementation details, see Validation and error state on the Code page.
Additional guidelines
- If a textarea does not have an associated
<label>element, anaccessible-labelattribute is required. - Help text content (via
help-textattribute orhelp-textslot) is automatically linked to the control viaariaDescribedByElementsso screen readers announce it.
ARIA Authoring Practices Guide (APG)
Learn to use the accessibility semantics defined by the Accessible Rich Internet Application (ARIA) specification to create accessible web experiences.
Web Content Accessibility Guidelines
Automated testing
Some of our elements may receive errors or warnings that are false positives from automated testing tools. If you are experiencing some of these issues, please read our update on false positives in automated tools.
Understanding documents provide detailed explanations for Web Content Accessibility Guidelines (WCAG) guidelines and success criteria.
-
SC 1.3.1 Info and relationships (Level A)
-
SC 2.1.1 Keyboard (Level A)
-
SC 2.1.3 Keyboard (no exception) (Level AAA)
-
SC 2.4.3 Focus order (Level A)
-
SC 2.4.7 Focus visible (Level AA)
-
SC 2.5.5 Target size (Level AAA)
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.