WCAG Accessibility Audit & Compliance Analysis
Comprehensive accessibility audit prompt for Next.js/React codebases. Scans for WCAG 2.2 Level AA compliance issues including semantic HTML, keyboard navigation, ARIA usage, form accessibility, color contrast, dynamic content announcements, and responsive/motion considerations. Outputs prioritized findings with specific code fixes, affected WCAG criteria, and user impact assessments.
# Accessibility Audit & WCAG Compliance Analysis ## Objective Perform a comprehensive accessibility audit of this codebase to identify WCAG 2.2 compliance issues, focusing on Level AA conformance (the standard legal/professional target) while noting Level AAA opportunities. ## Analysis Tasks ### 1. Semantic HTML Structure Scan the entire codebase for: - **Missing landmark elements**: Pages without proper `<main>`, `<nav>`, `<header>`, `<footer>`, `<aside>`, `<section>`, `<article>` structure - **Heading hierarchy violations**: Skipped heading levels (h1 → h3), multiple h1s per page, missing h1s - **Div/span soup**: Clickable divs that should be buttons, div lists that should be `<ul>`/`<ol>`, etc. - **Incorrect element usage**: Using `<a>` for buttons, `<div>` for interactive elements, tables for layout - **Missing document language**: No `lang` attribute on `<html>` For each violation found, provide: - Location (file paths and line numbers) - The problematic code - WCAG criterion violated (e.g., "1.3.1 Info and Relationships") - Concrete fix with corrected semantic HTML ### 2. Keyboard Navigation & Focus Management Identify issues with: - **Non-focusable interactive elements**: Clickable elements without proper focus capability - **Missing focus indicators**: Elements with `outline: none` or `outline: 0` without replacement styles - **Focus traps**: Modals, dropdowns, or dialogs that trap or lose focus incorrectly - **Tab order issues**: Illogical tab sequences, positive tabindex values, missing tabindex where needed - **Missing skip links**: No "Skip to main content" link at page start - **Keyboard-inaccessible functionality**: Features only accessible via mouse (hover-only menus, drag-only interfaces) For each issue: - Demonstrate the keyboard navigation problem - Provide the fix with proper focus management code - Note any custom hook opportunities (e.g., `useFocusTrap`, `useRovingTabIndex`) ### 3. ARIA Usage Audit Check for: - **Missing ARIA where needed**: - Custom components lacking proper roles - Dynamic content without `aria-live` regions - Expandable elements missing `aria-expanded` - Current page/item missing `aria-current` - Loading states without `aria-busy` - **Incorrect ARIA usage**: - `aria-label` on non-interactive elements - Redundant ARIA (e.g., `role="button"` on `<button>`) - Invalid ARIA attribute values - `aria-hidden="true"` on focusable elements - Missing required ARIA attributes for roles - **ARIA that could be replaced with semantic HTML**: - `role="navigation"` instead of `<nav>` - `role="main"` instead of `<main>` - Complex ARIA patterns where native elements suffice ### 4. Form Accessibility Evaluate all forms for: - **Label associations**: Inputs without associated `<label>` elements or `aria-label`/`aria-labelledby` - **Error handling**: - Error messages not programmatically associated with inputs (`aria-describedby`) - Missing `aria-invalid` on errored fields - Error announcements not using `aria-live` - **Required field indication**: Missing `aria-required` or `required` attribute, visual-only required indicators - **Fieldset/legend usage**: Related inputs not grouped, radio/checkbox groups without fieldset - **Autocomplete attributes**: Missing `autocomplete` for common fields (name, email, address, etc.) - **Input purpose**: Missing `inputmode` for appropriate keyboard types on mobile ### 5. Image & Media Accessibility Scan for: - **Missing alt text**: Images without `alt` attribute - **Decorative images**: Images that should have `alt=""` or `aria-hidden="true"` but don't - **Non-descriptive alt text**: Alt text like "image", "photo", "icon", or filename - **Complex images**: Charts, graphs, infographics without adequate text alternatives - **SVG accessibility**: Inline SVGs missing `role="img"` and `aria-label` or `<title>` - **Icon buttons**: Icon-only buttons without accessible names - **Background images with meaning**: CSS background images conveying information without text alternative - **Video/audio content**: Missing captions, transcripts, or audio descriptions ### 6. Color & Visual Design Check for: - **Color contrast violations**: - Text below 4.5:1 ratio (normal text) - Large text below 3:1 ratio (18pt+ or 14pt bold) - UI components and graphics below 3:1 ratio - Focus indicators below 3:1 ratio - **Color-only information**: Status indicators, form errors, charts relying solely on color - **Text over images**: Text on variable backgrounds without ensuring contrast - **Link distinction**: Links not distinguishable from surrounding text without color alone For contrast issues, provide: - Current colors and their contrast ratio - Suggested accessible color alternatives - Consider both light and dark mode if applicable ### 7. Dynamic Content & State Changes Identify problems with: - **Toast/notification announcements**: Alerts not announced to screen readers - **Loading states**: Spinners/skeletons without screen reader feedback - **Infinite scroll/pagination**: New content not announced, focus management issues - **Single Page App navigation**: Route changes not announced, focus not managed - **Conditional rendering**: Content appearing/disappearing without announcement - **Real-time updates**: Live data not using appropriate `aria-live` regions ### 8. Responsive & Zoom Accessibility Check for: - **Reflow issues**: Content not accessible at 320px viewport (400% zoom equivalent) - **Text resize**: Functionality broken when text resized to 200% - **Horizontal scrolling**: Two-dimensional scrolling required to read content - **Touch targets**: Interactive elements smaller than 44x44px on mobile - **Viewport meta issues**: `maximum-scale=1` or `user-scalable=no` preventing zoom ### 9. Motion & Animation Evaluate: - **Respect for `prefers-reduced-motion`**: Animations not disabled/reduced for users who prefer it - **Auto-playing content**: Videos, carousels, or animations that auto-play without pause control - **Parallax effects**: Motion effects that could cause vestibular issues - **Flashing content**: Any content flashing more than 3 times per second ### 10. Next.js Specific Accessibility Check for: - **next/link usage**: Proper accessible names, avoiding wrapping issues - **next/image alt text**: All Image components with appropriate alt - **Route change announcements**: Focus management on navigation - **Loading/error UI accessibility**: loading.tsx and error.tsx with proper announcements - **Metadata for accessibility**: Proper page titles changing on navigation - **Client component boundaries**: ARIA state that might need client-side handling ### 11. Component Library & Third-Party Dependencies Audit: - **UI library accessibility**: shadcn/ui, Radix, Headless UI components configured correctly - **Third-party widgets**: Any embedded content (maps, videos, social feeds) with accessibility issues - **Custom component overrides**: Accessible components made inaccessible through customization ## Output Format For each issue found, provide: ### [Issue Category] **WCAG Criterion**: X.X.X - Criterion Name (Level A/AA/AAA) **Priority**: Critical/High/Medium/Low **File**: `path/to/file.tsx` **Line(s)**: XX-XX **Issue**: Brief description of the accessibility barrier **Current Code**: ```tsx // Problematic code ``` **Accessible Solution**: ```tsx // Fixed code with proper accessibility ``` **User Impact**: Who is affected and how (screen reader users, keyboard users, low vision users, etc.) **Testing Method**: How to verify the fix (screen reader, keyboard, browser dev tools, etc.) --- ## Testing Recommendations After completing the analysis, suggest: ### Automated Testing Setup - Recommended accessibility linting rules (eslint-plugin-jsx-a11y configuration) - Automated testing integration (axe-core, jest-axe, Playwright accessibility testing) - CI/CD accessibility gates ### Manual Testing Checklist - Screen reader testing (NVDA, VoiceOver, JAWS) - Keyboard-only navigation testing - Browser zoom testing (up to 400%) - High contrast mode testing - Reduced motion testing ## Prioritization Provide a prioritized remediation plan: ### 1. Critical (Legal Risk / Complete Barriers) Issues that completely block access for users with disabilities - Missing form labels - No keyboard access to core functionality - Images without alt text conveying critical information ### 2. High Priority (Significant Barriers) Issues causing major difficulty but with possible workarounds - Poor focus management - Missing ARIA for custom components - Color contrast failures ### 3. Medium Priority (Moderate Impact) Issues causing frustration or extra effort - Suboptimal heading structure - Missing skip links - Verbose or unclear alt text ### 4. Low Priority / Enhancements (Level AAA) Nice-to-have improvements beyond Level AA - Enhanced focus indicators - Additional ARIA descriptions - Sign language alternatives for video ## Constraints - Maintain visual design while improving accessibility - Prefer native HTML solutions over ARIA when possible - Ensure fixes don't break existing functionality - Consider performance implications of accessibility fixes - Note when fixes require design review or approval ## Additional Notes - Flag any patterns that should become reusable accessible components - Suggest opportunities for accessibility-focused custom hooks - Identify any third-party dependencies with known accessibility issues - Note testing coverage gaps for accessibility Begin the comprehensive accessibility audit now. Be thorough and provide actionable, specific fixes for each issue found.
