accessibility-implementation
Cross-cutting accessibility guidance for design, implementation, and review. Apply the parts relevant to the current task; no agent-specific hooks are required.
When to load
- Designer — producing a Design Spec with any user-facing UI
- Implementer — implementing components, pages, forms, or interactive flows
- Reviewer — auditing a PR that touches HTML, JSX, or any UI code
- Problem — investigating a reported a11y incident
The 8 non-negotiables
-
Use native
<dialog>+showModal(). You get focus trap, Escape, and inert background for free. Do not build a modal from<div>unless you have a reason that survives a 5-minute audit. (Native<dialog>has implicit modal semantics — do NOT addaria-modal='true'; the browser handles it.) -
Focus management is non-negotiable. On open, focus moves into the dialog (capture
document.activeElement). On close, it returns to the trigger. A modal that drops focus on close is broken for keyboard users, even if it "looks fine." -
Never
autoFocusa destructive action. Delete, Remove, Reset must focus Cancel, the dialog itself, or nothing. autoFocusing Delete means a screen-reader user who hits Enter reflexively destroys their data. Destructive buttons must specify the object: "Delete account" not "Delete". -
ARIA fills gaps semantic HTML cannot.
aria-labelledbyandaria-describedbyon dialogs.aria-livefor state changes.aria-expandedfor disclosure widgets. If semantic HTML covers it, do not add ARIA.