Textarea accessibility
WCAG 2.1 AA requirements
Semantics
- Renders a native
<textarea>element, which is inherently accessible. aria-invalidis set automatically when theinvalidprop istrue.aria-requiredis set when therequiredprop istrue.
Label pairing
- Always pair with a
Labellinked viahtmlFor/id. Screen readers announce the label as the field's accessible name. - If a visible label is not possible, set
aria-labelon the Textarea directly.
Keyboard interaction
| Key | Action |
|---|---|
Tab | Move focus to the textarea. |
Shift+Tab | Move focus away from the textarea. |
| Typing | Standard text entry. |
No custom key handling needed — native <textarea> behaviour.
Focus ring
- A 2px focus ring (
ring-ring) appears onfocus-visiblewithring-offset-2. - The border also changes on focus to
border-ringfor additional visibility.
Error state
- The
destructivevariant changes border and text colour. Thearia-invalidattribute tells screen readers the field has an error. - Always pair with a visible error message. Connect it via
aria-describedbyfor screen reader announcement:
<Textarea id="notes" invalid aria-describedby="notes-error" />
<p id="notes-error" className="text-sm text-destructive">This field is required.</p>Disabled state
disabledsets native disabled attribute, implyingaria-disabled.- Visual treatment: 50% opacity and
cursor-not-allowed.
Audit checklist
- Paired with a
LabelviahtmlFor -
aria-invalidset on error -
aria-requiredset on required fields - Error message connected via
aria-describedby - Visible focus ring on keyboard navigation
- 4.5:1 contrast on text and placeholder in both themes