Accessibility Rules
WCAG 2.1 AA standards for code generation. The framework's accessibility agents apply these rules to every UI file they touch.
Semantic HTML
- Use
<button>for clickable actions, never<div>or<span>withonClick. - Use
<a>for navigation links, never<div>or<span>withonClick. - Use heading hierarchy correctly (
h1>h2>h3) — never skip levels. - Use landmark elements:
<main>,<nav>,<header>,<footer>,<aside>. - Use
<ul>or<ol>for lists of related items, not divs.
Forms
- Every input must have a visible
<label>element. - Labels must be associated with inputs via
htmlFor/id. - Never use placeholder as the only label.
- Mark required fields with
aria-required="true"and a visible indicator. - Group related inputs with
<fieldset>and<legend>. - Link error messages to inputs with
aria-describedby. - Use appropriate input types:
email,tel,url,number,password. - Add
autocompleteattributes for common fields (email, name, address, etc.).
Keyboard Accessibility
- All interactive elements must be keyboard accessible.
- Tab order must follow logical reading order.
- Focus indicators must be visible — never use
outline: nonewithout a replacement. - Custom components need keyboard handlers: Enter, Space, Escape, Arrow keys.
- No keyboard traps — users must be able to tab away from any element.
- Modals must trap focus while open and return focus when closed.
Images and Media
- All images must have an
altattribute. - Informative images:
altdescribes the content. - Decorative images:
alt=""(empty string). - Icons with meaning need accessible text (
aria-labelor visually hidden text). - Icons that are decorative use
aria-hidden="true".
ARIA
- Use ARIA only when native HTML is insufficient.
- Custom components must have appropriate
roleattributes. - Interactive components must have
aria-expanded,aria-selected, etc. as needed. - Use
aria-labelonly when visible text is insufficient. - Use
aria-describedbyfor additional context. - Use
aria-live="polite"to announce dynamic content changes. - Use
aria-live="assertive"only for critical alerts.
Color and Contrast
- Text contrast must be at least 4.5:1 (3:1 for large text 18px+ or 14px bold).
- UI component contrast must be at least 3:1.
- Never use color alone to convey information — add icons, text, or patterns.
- Focus indicators must have 3:1 contrast against background.
Dynamic Content
- Announce loading states to screen readers.
- Announce errors with
role="alert"oraria-live. - Manage focus when content changes (modals, page transitions, deletions).
- Single-page navigation must announce new page content.
Touch and Pointer
- Touch targets must be at least 44×44 CSS pixels.
- Provide alternatives to drag-and-drop interactions.
- Ensure click actions fire on pointer up, not down (allows cancel).
Related
- Accessibility guide — the three-prong approach (rules + tools + AI review).
- WCAG 2.1 reference — every success criterion by conformance level.
/hypr:a11yand/hypr:a11y-audit— commands that apply and verify these rules.