| name | accessibility-wcag |
| description | Expert guidance for web accessibility (WCAG 2.2). Treat a11y violations as compile errors. Use when implementing accessibility features, auditing a11y compliance, or working with screen readers. Triggers on: accessibility, wcag, a11y, aria, screen reader, keyboard navigation. |
Accessibility (WCAG 2.2)
Expert guidance for web accessibility. Treat a11y violations as compile errors.
Required Patterns
Icon Buttons
<IconButton aria-label="Close dialog">
<CloseIcon />
</IconButton>
<IconButton>
<CloseIcon />
</IconButton>
Custom Interactive Elements
<div
role="button"
tabIndex={0}
onKeyDown={handleKeyDown}
onClick={handleClick}
aria-pressed={isActive}
>
Toggle
</div>
Images
<img src="chart.png" alt="Q4 sales increased 25%" />
<img src="decoration.png" alt="" role="presentation" />
<img src="chart.png" />
Form Fields
<label htmlFor="email">Email</label>
<input id="email" type="email" />
<input aria-label="Search products" type="search" />
Error Announcements
<div role="alert" aria-live="polite">
{error && <span>{error}</span>}
</div>
Focus Management
:focus-visible {
outline: 2px solid #0066cc;
outline-offset: 2px;
}
:focus {
outline: none;
}
Modal Focus Trap
useEffect(() => {
const modal = modalRef.current;
const focusableElements = modal.querySelectorAll(
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
);
const firstElement = focusableElements[0];
const lastElement = focusableElements[focusableElements.length - 1];
firstElement?.focus();
}, [isOpen]);
Keyboard Navigation
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
handleAction();
}
if (e.key === 'Escape') {
handleClose();
}
}}
WCAG 2.2 New Requirements
| Criterion | Description |
|---|
| 2.5.8 Target Size | Minimum 24x24 CSS pixels |
| 2.4.12 Focus Not Obscured | Focus indicator not hidden |
| 3.3.7 Redundant Entry | Don't ask for same info twice |
Quick Checklist
Activation Keywords
accessibility-wcag
accessibility-wcag
accessibility wcag
Tools Used
Instructions for Agents
- Read the task description carefully
- Follow the step-by-step process
- Use the appropriate tools
- Verify the results
Examples
Example 1: Basic Usage
User:
Agent:
Example 2: Advanced Usage
User:
Agent: