| name | docs-creating-accessible-diagrams |
| description | WCAG-compliant Mermaid diagrams using verified accessible color palette. Use when creating diagrams, flowcharts, or any color-dependent visualizations requiring accessibility compliance for color blindness. |
Color Accessibility for Diagrams
This Skill provides guidance on creating accessible Mermaid diagrams using a verified color-blind friendly palette that meets WCAG AA standards. Use this when creating visual diagrams to ensure accessibility for all users, including those with color blindness (~300 million people worldwide).
Purpose
Use this Skill when:
- Creating Mermaid diagrams, flowcharts, or visualizations
- Working with color-dependent visual content
- Need to ensure WCAG compliance for diagrams
- Supporting users with color blindness (protanopia, deuteranopia, tritanopia)
- Choosing colors for documentation, diagrams, or UI components
Verified Accessible Color Palette
CRITICAL: Use ONLY these colors in all diagrams. This palette is scientifically verified to work for all color blindness types and meets WCAG AA standards.
| Color | Hex Code | Use Cases | WCAG AA (Light) | WCAG AA (Dark) |
|---|
| Blue | #0173B2 | Primary elements, main flow | โ
8.59:1 (AAA) | โ
6.93:1 (AAA) |
| Orange | #DE8F05 | Warnings, decisions, secondary | โ
6.48:1 (AAA) | โ
5.24:1 (AAA) |
| Teal | #029E73 | Success, validation, tertiary | โ
8.33:1 (AAA) | โ
6.74:1 (AAA) |
| Purple | #CC78BC | Special states, implementors | โ
4.51:1 (AA) | โ
3.65:1 (AA) |
| Brown | #CA9161 | Neutral elements, secondary | โ
5.23:1 (AAA) | โ
4.23:1 (AAA) |
| Black | #000000 | Text on light, borders | โ
21.00:1 (AAA) | N/A |
| White | #FFFFFF | Text on dark, backgrounds | N/A | โ
21.00:1 (AAA) |
| Gray | #808080 | Disabled, secondary elements | โ
7.00:1 (AAA) | โ
4.00:1 (AA) |
Quick copy-paste hex codes:
#0173B2 - Blue
#DE8F05 - Orange
#029E73 - Teal
#CC78BC - Purple
#CA9161 - Brown
#000000 - Black
#FFFFFF - White
#808080 - Gray
Colors to NEVER Use
CRITICAL: Never use these colors where color conveys information:
- โ Red (#FF0000, #E74C3C) - Invisible to protanopia/deuteranopia (~8% of males)
- โ Green (#00FF00, #27AE60) - Invisible to protanopia/deuteranopia
- โ Yellow (#FFFF00, #F1C40F) - Invisible to tritanopia (rare but severe)
- โ Light Pink (#FF69B4, #FFC0CB) - Severely compromised for tritanopia
- โ Bright Magenta (#FF00FF, #FF1493) - Problematic for all types
- โ Red-Green combinations - Creates impossible contrast for ~8% of males
Exception: Emoji indicators (๐ด๐ ๐ก๐ข) can use standard colors when ALWAYS paired with text labels (color is supplementary, not primary identifier).
Core Accessibility Principles
1. Never Rely on Color Alone
Always combine color with:
- โ
Text labels - Clear descriptions
- โ
Shape differentiation - Different node shapes (rectangles, diamonds, circles)
- โ
Line styles - Solid, dashed, dotted
- โ
Position - Spatial organization
- โ
Icons - Additional visual markers
Example:
- โ Bad: Red node means "error" (color only)
- โ
Good: Orange diamond labeled "Error State" with error icon
2. Use Color as Enhancement
Color should enhance information already conveyed through other means. A grayscale version should remain understandable.
3. Maintain WCAG AA Contrast
All text and UI components must meet minimum contrast:
- Normal text: 4.5:1 minimum
- Large text (18pt+ or 14pt+ bold): 3:1 minimum
- UI components/graphics: 3:1 minimum
4. Test for Color Blindness
Before publishing diagrams:
- Create using accessible palette
- Test in color blindness simulator (protanopia, deuteranopia, tritanopia)
- Verify contrast ratios with WebAIM checker
- Confirm shape differentiation sufficient
- Test in both light and dark modes
Mermaid Diagram Best Practices
Standard Mermaid Template with Accessibility
Use this as a starting point for all Mermaid diagrams:
%% Color Palette: Blue #0173B2, Orange #DE8F05, Teal #029E73, Purple #CC78BC, Brown #CA9161, Gray #808080
%% All colors are color-blind friendly and meet WCAG AA contrast standards
graph TD
A["Start Process<br/>Primary"]:::blue
B{"Decision Point<br/>Evaluate"}:::orange
C["Success Path<br/>Complete"]:::teal
D["Alternate Path<br/>Optional"]:::gray
A --> B
B -->|Yes| C
B -->|No| D
classDef blue fill:#0173B2,stroke:#000000,color:#FFFFFF,stroke-width:2px
classDef orange fill:#DE8F05,stroke:#000000,color:#FFFFFF,stroke-width:2px
classDef teal fill:#029E73,stroke:#000000,color:#FFFFFF,stroke-width:2px
classDef gray fill:#808080,stroke:#000000,color:#FFFFFF,stroke-width:2px
Essential Mermaid Rules
- Always include palette comment - First line documents colors used
- Use classDef with accessible hex codes - REQUIRED for accessibility
- Include black borders -
stroke:#000000 for shape definition
- Use white text on dark fills -
color:#FFFFFF for readability
- Use black text on light fills -
color:#000000 when needed
- 2px stroke width -
stroke-width:2px for visibility
- Provide descriptive labels - Never use color-only identification
- Prefer vertical orientation -
graph TD (top-down) for mobile viewing
- Use different shapes - Rectangles, diamonds, circles for differentiation
- Escape special characters - Parentheses, brackets, braces in node text
Mermaid Comment Syntax (CRITICAL)
CORRECT - Use double-percent for comments:
%% This is a comment
%% Color palette: Blue #0173B2, Orange #DE8F05
WRONG - Do NOT use this syntax (causes syntax errors):
%%{ This breaks rendering }%%
Escaping Special Characters in Mermaid
CRITICAL: Escape special characters in node text AND edge labels to prevent syntax errors:
| Character | Entity Code | Example Usage |
|---|
( | #40; | A[Function#40;param#41;] |
) | #41; | Same as above |
[ | #91; | B[Array#91;index#93;] |
] | #93; | Same as above |
{ | #123; | C[Object#123;key#125;] |
} | #125; | Same as above |
< | #60; | D[Generic#60;T#62;] |
> | #62; | Same as above |
Edge labels also need escaping:
A -->|Function#40;param#41;| B
Avoid literal quotes - Remove or use descriptive text instead:
- โ
F[let x = "hello"] - Breaks rendering
- โ
F[let x = hello] - Works correctly
- โ
F[Variable Assignment] - Descriptive alternative
Common Mistakes to Avoid
Mistake 1: Using Red-Green Combinations
โ Problem: ~8% of males cannot distinguish red/green
โ
Solution: Use Orange and Teal from verified palette
Mistake 2: Relying on Color Alone
โ Problem: Color-blind users can't distinguish elements
โ
Solution: Add text labels, use different shapes, provide context
Mistake 3: Using Yellow for Important Info
โ Problem: Yellow invisible to tritanopia (blue-yellow blindness)
โ
Solution: Use Orange or Teal instead
Mistake 4: No Contrast Verification
โ Problem: Insufficient contrast causes readability issues
โ
Solution: Use verified palette (all colors tested for WCAG AA)
Mistake 5: Using CSS Color Names
โ Problem: Inconsistent across platforms
fill: red;
โ
Solution: Always use hex codes
fill: #de8f05;
Mistake 6: Not Testing Dark Mode
โ Problem: Colors may not work in dark backgrounds
โ
Solution: Verified palette works in both light and dark modes
Testing Tools
Color Blindness Simulators
Contrast Checkers
Integration with Repository Conventions
This Skill integrates with:
Quick Reference
Verified Palette (Copy-Paste):
Blue: #0173B2 - Primary flow
Orange: #DE8F05 - Decisions, warnings
Teal: #029E73 - Success, validation
Purple: #CC78BC - Special states
Brown: #CA9161 - Neutral
Gray: #808080 - Secondary, disabled
Black: #000000 - Borders, text
White: #FFFFFF - Text on dark
Mermaid classDef Template:
classDef blue fill:#0173B2,stroke:#000000,color:#FFFFFF,stroke-width:2px
classDef orange fill:#DE8F05,stroke:#000000,color:#FFFFFF,stroke-width:2px
classDef teal fill:#029E73,stroke:#000000,color:#FFFFFF,stroke-width:2px
classDef purple fill:#CC78BC,stroke:#000000,color:#FFFFFF,stroke-width:2px
classDef brown fill:#CA9161,stroke:#000000,color:#FFFFFF,stroke-width:2px
classDef gray fill:#808080,stroke:#000000,color:#FFFFFF,stroke-width:2px
Pre-commit Checklist:
Examples
See examples.md in this Skill directory for complete working examples:
- Accessible flowchart
- Sequence diagram with colors
- Architecture diagram
- Common mistakes and corrections
References
Related Skills
repository-architecture - Understanding how accessibility fits into governance layers
apps-ayokoding-www-developing-content - ayokoding-web diagram requirements
factual-validation-methodology (Phase 2) - Verifying color accessibility claims
Note: This Skill provides action-oriented guidance for creating accessible diagrams. The authoritative Color Accessibility Convention contains complete scientific research, WCAG standards, and detailed testing procedures.