Skip to content

Validate ARIA Implementation Against WAI-ARIA Authoring Practices

Accessibility TestingUpdated 2026-10-21advanced
TL;DR

Reads a component's ARIA implementation (role + states + keyboard handling) and validates against the matching WAI-ARIA Authoring Practices Guide pattern: flagging missing required roles, missing required states/properties, incorrect keyboard interactions, and prohibited attribute use.

When to use it

  • Building or reviewing a custom widget that needs WAI-ARIA support (combobox, treegrid, menubar).
  • Auditing a component library for ARIA correctness.
  • Validating that a third-party component matches WAI-ARIA spec.
  • Teaching engineers WAI-ARIA patterns by showing the gaps in their implementation.

The prompt

XML-tagged: works best with Claude
aria-patterns-validator.claude.mdprompt
<role>You are a WAI-ARIA specialist who has read the WAI-ARIA Authoring Practices Guide (APG) cover to cover. You know that ARIA is a contract, not decoration, and getting it wrong produces worse accessibility than no ARIA at all.</role> <context>WAI-ARIA Authoring Practices Guide (APG) defines reference patterns for common widgets: button, checkbox, combobox, dialog, disclosure, listbox, menu, menubar, radio, slider, switch, tablist, treegrid, etc. Each pattern specifies required roles, required states/properties, keyboard interactions, and focus management. The most common ARIA bugs:- Wrong role (using `role="button"` on a span when `<button>` would work natively)- Missing required states (combobox without aria-expanded)- Missing required keyboard interactions (tab list without arrow keys)- Using prohibited attributes (e.g., aria-checked on a non-checkable role)- Reinventing native semantics ("custom dropdown" when `<select>` works)</context> <task>For the component below:1. Identify which APG pattern it matches (or note "no exact pattern: closest is X").2. Check required roles: flag missing or wrong.3. Check required states / properties: flag missing or extra.4. Check keyboard interactions: flag missing keys or wrong behavior.5. Check prohibited attributes: flag any aria-* attribute not allowed on this role.6. Recommend whether to use native HTML instead (a common simplification).</task> <input>Component description (role, attributes, keyboard behavior): {component}Pattern claimed (combobox, dialog, etc.): {pattern}Implementation context (React / Vue / vanilla): {stack}</input> <constraints>- Cite the APG pattern URL or section.- Required vs optional states clearly distinguished.- Keyboard requirements MUST be enumerated key-by-key.- Prohibited attributes called out specifically (which attribute is not allowed for which role).- "Use native HTML" recommendation when applicable (avoids ARIA entirely).</constraints> <output_format>Five sections:1. **Pattern match**, which APG pattern + URL2. **Required roles**: table: Required role | Present? | Notes3. **Required states & properties**: table: State | Required? | Present? | Notes4. **Keyboard interactions**: table: Key | Expected behavior | Implemented? | Notes5. **Recommendations**: bullet list of fixes ordered by impact</output_format> <approach>Before writing, identify if the component should use native HTML instead: that's often the right answer.</approach>

Example

Input
Component description: Custom combobox for country selection. Implementation:
- Outer div with role="combobox"
- Input element with aria-controls="listbox-1"
- Visible dropdown div with role="listbox" id="listbox-1"
- Options have role="option"
- aria-selected on the focused option
- Down arrow opens the listbox and focuses first option
- Up/Down arrow navigates among options
- Enter selects the focused option
- aria-expanded NOT implemented
- aria-activedescendant NOT used
- Esc not handled

Pattern claimed: combobox (autocomplete listbox)
Stack: React
Output
## 1. Pattern match

**APG pattern: Combobox (combobox with listbox popup, also referred to as "select-only" or "autocomplete listbox" depending on variant).**
- URL: https://www.w3.org/WAI/ARIA/apg/patterns/combobox/
- Variants:
  - Combobox without autocomplete: text input + selectable list
  - Combobox with autocomplete (inline, list, both): input filters as you type
- Your implementation aligns with the "autocomplete listbox" variant.

## 2. Required roles

| Required role | Present? | Notes |
|---------------|----------|-------|
| role="combobox" on input | ⚠️ Wrong placement | Should be on the INPUT element, not the outer div. APG: role="combobox" goes on the input. |
| role="listbox" on dropdown | ✅ Present | Correct on the dropdown container |
| role="option" on options | ✅ Present | Correct |

## 3. Required states & properties

| State / property | Required? | Present? | Notes |
|------------------|-----------|----------|-------|
| aria-expanded on combobox | Required | ❌ MISSING | Must be on the combobox element, toggles "true" when open, "false" when closed |
| aria-controls on combobox | Required | ✅ Present | Correctly references listbox id |
| aria-activedescendant on combobox | Required for this design (DOM focus stays on the combobox while options are highlighted) | ❌ MISSING | The combobox should remain focused; activedescendant points at the active option without moving DOM focus |
| aria-autocomplete on combobox | Required for the autocomplete variant you claim | ❌ MISSING | Should be "list" for this variant ("none", "inline", "list", "both") |
| aria-selected on options | Optional | ✅ Present | Used here: note: aria-selected is REQUIRED if the listbox supports selection (yours does) |
| aria-disabled on combobox | Optional | (state not described) | Add when the combobox is non-interactive |
| aria-haspopup on combobox | Optional (default is "listbox") | (state not described) | Implied when role="combobox" is on the input; explicit "listbox" optional |

## 4. Keyboard interactions

| Key | Expected behavior | Implemented? | Notes |
|-----|-------------------|--------------|-------|
| Down Arrow (closed) | Open listbox + focus first option (or set activedescendant) | ✅ Implemented | Correct |
| Down Arrow (open) | Move activedescendant to next option | ✅ Implemented | Correct |
| Up Arrow (open) | Move activedescendant to previous option | ✅ Implemented | Correct |
| Up Arrow (closed) | Open listbox + focus LAST option | ❌ MISSING | Optional in APG, but users of the native select expect it |
| Enter (open, on option) | Select option + close listbox + move focus to combobox | ✅ Implemented | Correct |
| Esc (open) | Close listbox without selection + return focus to combobox | ❌ MISSING | Esc not handled |
| Esc (closed) | Optionally clear input | (not described) | Implementation choice: APG allows |
| Home (open) | Move activedescendant to first option (or move the text cursor) | ❌ MISSING | Optional in APG; recommended for long lists such as countries |
| End (open) | Move activedescendant to last option (or move the text cursor) | ❌ MISSING | Optional in APG; recommended for long lists |
| Tab | Move focus to next focusable element (close listbox) | (not described) | Verify in your implementation |
| Printable characters | Filter listbox (autocomplete) | (not described) | If this is the autocomplete variant, MUST filter: required |

## 5. Recommendations (impact-ordered)

1. **Add aria-expanded to the combobox**: this is the most critical missing state. Screen readers depend on it to announce open/closed.
2. **Move role="combobox" from outer div to the input element**: placement is part of the spec; wrong location breaks assistive tech.
3. **Implement aria-activedescendant pattern instead of moving DOM focus into the listbox**: the APG-recommended approach. Combobox stays focused; activedescendant points at the active option. Avoids focus management bugs.
4. **Implement Esc to close the listbox and return focus to the combobox**: required keyboard interaction.
5. **Add aria-autocomplete="list" to the combobox**: required when the listbox filters based on input.
6. **Implement Home and End to jump to first/last option**: optional in APG, but valuable in a 200-item list.
7. **Implement Up Arrow on closed combobox to open + focus last option**: optional in APG, matches native select behavior.
8. **If users never type to filter, use a native `<select>`**: it is keyboard- and screen-reader-correct with zero ARIA. Avoid `<datalist>` as a shortcut: its screen-reader and zoom support is still inconsistent across browsers. A custom combobox is justified when you need filtering or rich options.

Common pitfalls

  • APG pattern not cited; recommendations become subjective. Force the URL or section reference.
  • Required vs optional gets blended; reviewers can't tell which are blockers.
  • Keyboard interactions listed as 'arrow keys work' without enumerating each key. Demand key-by-key table.
  • Native HTML alternative skipped: APG often says 'consider native first'. The model should call this out.

Tips

  • Bookmark the APG pattern URL for every widget your team builds: it's the single best reference.
  • Run this prompt during PR review of any new custom widget: catches issues before merge.
  • Pair with `screen-reader-scenarios` to validate the announcement of the corrected ARIA.
  • Consider using a library that implements APG patterns (Reach UI, Radix UI, Headless UI) instead of building from scratch.

FAQ

When should I use native HTML vs ARIA?

Always prefer native HTML when possible. `<button>` over `role="button"`. `<dialog>` over `role="dialog"`. `<details>` over disclosure widget. Native HTML provides accessibility, keyboard handling, and focus management for free. ARIA is for cases where native HTML doesn't fit (custom comboboxes, tab lists, etc.).

What's the relationship between APG and the ARIA spec?

ARIA spec defines what each role / attribute means. APG defines how to USE them correctly: the patterns, the keyboard interactions, the focus management. Implementing ARIA without reading APG produces incorrect implementations.

Can I just use the WAI-ARIA spec directly?

You can, but you'll re-derive the patterns. APG packaged the spec into recipes for common widgets. Use APG; refer to the spec only for edge cases.

What about testing the implementation, not just the markup?

Use both: this prompt validates the markup. Then test with screen readers (use `screen-reader-scenarios`). Some bugs only surface in actual assistive tech, not in static analysis.