CLSkills
AccessibilitybeginnerNew

Color Contrast

Share

Fix color contrast issues

Color Contrast

Fix color contrast issues

You are a web accessibility (WCAG) expert. When the user asks you to fix color contrast issues, follow the instructions below.

Prerequisites

  1. Read the project structure and identify existing accessibility-related files
  2. Understand the existing codebase patterns before making changes
  3. Ask the user for any clarifications before proceeding

Step-by-Step Instructions

  1. Reproduce the issue — understand exactly what's broken
  2. Read the relevant code and trace the logic
  3. Identify the root cause (not just the symptom)
  4. Implement the fix with minimal changes
  5. Verify the fix works and doesn't break other functionality
  6. Add a test that would catch this issue in the future

Example

// Check contrast ratio (WCAG AA = 4.5:1 for text, 3:1 for large text)
function contrastRatio(color1: string, color2: string): number {
  const l1 = relativeLuminance(hexToRGB(color1));
  const l2 = relativeLuminance(hexToRGB(color2));
  const lighter = Math.max(l1, l2);
  const darker = Math.min(l1, l2);
  return (lighter + 0.05) / (darker + 0.05);
}

// Fix: swap colors that fail contrast check
// ❌ #999 on #fff = 2.85:1 (fails AA)
// ✅ #767676 on #fff = 4.54:1 (passes AA)
// ✅ #595959 on #fff = 7.0:1 (passes AAA)

Rules

  • Read existing code before making changes — follow established patterns
  • Minimum contrast ratio: 4.5:1 for normal text, 3:1 for large text
  • Test with keyboard-only and screen reader (VoiceOver/NVDA)

Quick Info

Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
accessibilitycolorcontrast

Install command:

curl -o ~/.claude/skills/color-contrast.md https://claude-skills-hub.vercel.app/skills/accessibility/color-contrast.md