Cursor rule
.cursor/rules/color-contrast-accessibility.mdcText and user interface color contrast compliance with WCAG 2.2 1.4.3 and 1.4.11
Cursor rules
Quality
44/100
Scores the file, not the repository.Length
1,181 words
1 headings · 5 code blocksRepository
428
— · pushed 17 days agoLast changed
3 days ago
First indexed 3 days ago.123456# Color Contrast Accessibility Standards78Ensures color contrast meets WCAG 2.2 1.4.3: Contrast (Minimum) and 1.4.11: Non-text Contrast requirements.910<rule>11name: color_contrast_accessibility_standards12description: Enforce color contrast accessibility standards per WCAG 2.2 1.4.3 and 1.4.1113filters:14 - type: file_extension15 pattern: "\\.(css|scss|sass|less|vue|jsx|tsx|html|liquid|php|js|ts)$"1617actions:18 - type: enforce19 conditions:20 # Common low-contrast text color combinations21 - pattern: "color:\\s*#[89abcdefABCDEF]{6}"22 message: "Light text colors may not meet 4.5:1 contrast ratio requirement. Verify contrast against background."2324 - pattern: "color:\\s*#[0-6]{6}"25 message: "Very light text colors likely fail contrast requirements. Use darker colors for better accessibility."2627 # Light gray text (common accessibility issue)28 - pattern: "color:\\s*(#[cdefCDEF]{3,6}|lightgray|lightgrey|silver)"29 message: "Light gray text often fails WCAG contrast requirements (4.5:1 minimum). Use darker colors."3031 # Common problematic color combinations32 - pattern: "background.*#fff.*color.*#[89abcdefABCDEF]"33 message: "Light text on white background may not meet 4.5:1 contrast ratio requirement."3435 - pattern: "background.*#f[0-9a-fA-F]{5}.*color.*#[89abcdefABCDEF]"36 message: "Light text on light background may not meet contrast requirements."3738 # UI component border/focus indicators39 - pattern: "border.*#[cdefCDEF]{3,6}"40 message: "Light borders may not meet 3:1 non-text contrast requirement for UI components."4142 - pattern: "outline.*#[cdefCDEF]{3,6}"43 message: "Light focus outlines may not meet 3:1 contrast requirement for UI component identification."4445 # Button states with insufficient contrast46 - pattern: "button.*background.*#[cdefCDEF]{3,6}"47 message: "Light button backgrounds may not provide sufficient 3:1 contrast for UI component identification."4849 # Form input borders50 - pattern: "input.*border.*#[defDEF]{3,6}"51 message: "Very light input borders may not meet 3:1 contrast requirement for form field identification."5253 # SVG icon fill colors that may lack contrast54 - pattern: "fill=\"#[cdefCDEF]{3,6}\""55 message: "Light SVG fill colors may not meet 3:1 contrast requirement for icon identification."5657 # SVG stroke colors for icon outlines58 - pattern: "stroke=\"#[defDEF]{3,6}\""59 message: "Very light SVG stroke colors may not provide sufficient contrast for icon visibility."6061 # Missing prefers-contrast considerations62 - pattern: "@media\\s*\\(prefers-contrast:\\s*more\\)"63 pattern_negate: "color|background|border"64 message: "prefers-contrast: more media query should include enhanced color/contrast properties."6566 - type: suggest67 message: |68 **WCAG 2.2 Color Contrast Requirements:**6970 **1.4.3: Text Contrast (Minimum) - Level AA:**71 - **Normal Text:** Minimum 4.5:1 contrast ratio72 - **Large Text:** Minimum 3:1 contrast ratio (18pt+ regular or 14pt+ bold)73 - **Enhanced (Level AAA):** 7:1 for normal text, 4.5:1 for large text7475 **1.4.11: Non-text Contrast - Level AA:**76 - **UI Components:** Minimum 3:1 contrast ratio for component identification77 - **Focus Indicators:** Minimum 3:1 contrast ratio for focus visibility78 - **Graphical Objects:** Minimum 3:1 contrast ratio for content understanding7980 **Exceptions (No Contrast Requirement):**81 - Inactive/disabled UI components82 - Pure decorative elements83 - Text in logos or brand names84 - Text that is not visible to users85 - Graphics where specific presentation is essential8687 **High Contrast Color Combinations:**8889 **Dark Text on Light Backgrounds:**90 - `#212529` on `#ffffff` - 16.6:1 ✅91 - `#495057` on `#ffffff` - 8.3:1 ✅92 - `#6c757d` on `#ffffff` - 5.4:1 ✅93 - `#343a40` on `#f8f9fa` - 11.7:1 ✅9495 **Light Text on Dark Backgrounds:**96 - `#ffffff` on `#212529` - 16.6:1 ✅97 - `#f8f9fa` on `#495057` - 7.0:1 ✅98 - `#ffffff` on `#0056b3` - 7.7:1 ✅99 - `#ffffff` on `#dc3545` - 5.8:1 ✅100101 **UI Component Colors (3:1 minimum):**102 - Focus outlines: `#0056b3`, `#dc3545`, `#198754`103 - Border colors: `#ced4da`, `#adb5bd`, `#6c757d`104 - Button states: `#0056b3`, `#157347`, `#b02a37`105106 **Implementation Examples:**107108 **CSS Text Contrast:**109```css110 /* Good: High contrast text */111 .primary-text {112 color: #212529;113 background: #ffffff;114 }115116 .secondary-text {117 color: #495057;118 background: #ffffff;119 }120121 /* Good: Large text with 3:1 minimum */122 .large-heading {123 font-size: 18px;124 font-weight: normal;125 color: #6c757d;126 background: #ffffff;127 }128```129130 **CSS UI Component Contrast:**131```css132 /* Good: Form inputs with sufficient border contrast */133 .form-control {134 border: 2px solid #ced4da; /* 3:1+ contrast */135 background: #ffffff;136 }137138 .form-control:focus {139 border-color: #0056b3; /* High contrast focus */140 outline: 3px solid #0056b3;141 outline-offset: 2px;142 }143144 /* Good: Button states */145 .btn-primary {146 background: #0056b3;147 color: #ffffff;148 border: 1px solid #004085;149 }150```151152 **Contrast Testing:**153 - Use browser dev tools color picker for contrast ratios154 - Test with tools like WebAIM Contrast Checker155 - Verify with automated accessibility testing tools156 - Test with actual users who have visual impairments157158 **Common Problematic Combinations to Avoid:**159 - Light gray text (#999999) on white backgrounds160 - Yellow text (#ffff00) on white backgrounds161 - Light blue links (#87ceeb) on white backgrounds162 - Thin borders (#e0e0e0) for essential UI components163 - Low contrast placeholder text164 - Insufficient focus indicator contrast165166 **Responsive Considerations:**167 - Maintain contrast ratios across all screen sizes168 - Consider dark mode color schemes169 - Test contrast in different lighting conditions170 - Ensure contrast is maintained with CSS filters/effects171172 **CSS `prefers-contrast` Media Query:**173 The `prefers-contrast` media query allows adaptation to user contrast preferences:174175```css176 /* Default styles */177 .button {178 background: #0056b3;179 color: #ffffff;180 border: 1px solid #004085;181 }182183 /* High contrast preference */184 @media (prefers-contrast: more) {185 .button {186 background: #000000;187 color: #ffffff;188 border: 2px solid #ffffff;189 font-weight: bold;190 }191192 .text-secondary {193 color: #000000; /* Increase from gray to black */194 }195196 .form-control {197 border: 3px solid #000000; /* Thicker, darker borders */198 }199 }200201 /* Low contrast preference (rare) */202 @media (prefers-contrast: less) {203 .high-contrast-element {204 /* Reduce contrast only where specifically needed */205 /* Still maintain minimum WCAG requirements */206 }207 }208209 /* Custom contrast preference */210 @media (prefers-contrast: custom) {211 /* Allow user-defined contrast settings */212 /* Respect system/browser contrast customizations */213 }214```215216 **Icon Accessibility & Contrast Requirements:**217 Icons are UI components and must meet 3:1 contrast ratio for identification:218219 **SVG Icon Examples:**220```html221 <!-- Good: High contrast icon -->222 <svg width="24" height="24" viewBox="0 0 24 24"223 aria-label="Close dialog" role="img">224 <path fill="#212529"225 d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>226 </svg>227228 <!-- Good: Icon with sufficient background contrast -->229 <button class="icon-button" aria-label="Save document">230 <svg width="20" height="20" viewBox="0 0 24 24">231 <path fill="#ffffff"232 d="M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V7l-4-4z"/>233 </svg>234 </button>235236 /* CSS for icon button with 3:1 contrast */237 .icon-button {238 background: #0056b3; /* High contrast background */239 border: 2px solid #004085; /* Visible border for component identification */240 padding: 8px;241 border-radius: 4px;242 }243244 .icon-button:focus {245 outline: 3px solid #ffd700; /* High contrast focus indicator */246 outline-offset: 2px;247 }248```249250 **Icon Contrast Considerations:**251 - **Informative Icons:** Must meet 3:1 contrast against background252 - **Decorative Icons:** No contrast requirement (use `aria-hidden="true"`)253 - **Icon Buttons:** Both icon and button background need sufficient contrast254 - **State Icons:** Different states (active/inactive) need distinguishable contrast255 - **Icon + Text:** Ensure both elements meet their respective requirements256257 **Complex Icon Examples:**258```css259 /* Multi-state icon button */260 .toggle-icon {261 background: #f8f9fa;262 border: 2px solid #6c757d; /* 3:1+ contrast for UI component */263 color: #495057;264 }265266 .toggle-icon[aria-pressed="true"] {267 background: #0056b3;268 color: #ffffff;269 border-color: #004085;270 }271272 /* Icon with adaptive contrast */273 @media (prefers-contrast: more) {274 .icon-subtle {275 filter: contrast(150%); /* Increase icon contrast */276 }277278 .icon-button {279 border-width: 3px; /* Thicker borders for better identification */280 }281 }282```283284 **Design System Approach:**285 - Establish a palette of WCAG-compliant color combinations286 - Document contrast ratios for all color pairs287 - Create design tokens with built-in accessibility288 - Implement automated contrast checking in build process289 - Define icon contrast standards for different contexts290 - Test icons across different contrast preferences291292metadata:293 priority: high294 version: 1.0295</rule>296
Also in Shopify/horizon
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| Shopify/horizon.cursor/rules/accordion-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/animation-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/blocks.mdc · 428 | Cursor rules | stylearchtypesdatabase+2 | 62/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/breadcrumb-accessibility.mdc · 428 | Cursor rules | ui | 36/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/carousel-accessibility.mdc · 428 | Cursor rules | ui | 32/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/cart-drawer-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/chat-window-accessibility.mdc · 428 | Cursor rules | styleui | 24/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/color-swatch-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/commit-messages.mdc · 428 | Cursor rules | setuplint-formattypesgit | 62/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/css-standards.mdc · 428 | Cursor rules | stylearchuiperformance+3 | 49/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/disclosure-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/dropdown-navigation-accessibility.mdc · 428 | Cursor rules | styleui | 36/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/flip-card-accessibility.mdc · 428 | Cursor rules | styleui | 36/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/form-accessibility.mdc · 428 | Cursor rules | ui | 32/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/javascript-standards.mdc · 428 | Cursor rules | stylearchtypesui+2 | 54/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/landmark-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/liquid.mdc · 428 | Cursor rules | buildstyletypesdatabase+2 | 77/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/locales.mdc · 428 | Cursor rules | arch | 49/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/localization.mdc · 428 | Cursor rules | style | 54/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/mobile-accessibility-standards.mdc · 428 | Cursor rules | styleui | 36/100 | 3 days ago |
Diff against .cursor/rules/accordion-accessibility.mdc Diff against .cursor/rules/animation-accessibility.mdc Diff against .cursor/rules/blocks.mdc Diff against .cursor/rules/breadcrumb-accessibility.mdc Diff against .cursor/rules/carousel-accessibility.mdc Diff against .cursor/rules/cart-drawer-accessibility.mdc Diff against .cursor/rules/chat-window-accessibility.mdc Diff against .cursor/rules/color-swatch-accessibility.mdc Diff against .cursor/rules/commit-messages.mdc Diff against .cursor/rules/css-standards.mdc Diff against .cursor/rules/disclosure-accessibility.mdc Diff against .cursor/rules/dropdown-navigation-accessibility.mdc Diff against .cursor/rules/flip-card-accessibility.mdc Diff against .cursor/rules/form-accessibility.mdc Diff against .cursor/rules/javascript-standards.mdc Diff against .cursor/rules/landmark-accessibility.mdc Diff against .cursor/rules/liquid.mdc Diff against .cursor/rules/locales.mdc Diff against .cursor/rules/localization.mdc Diff against .cursor/rules/mobile-accessibility-standards.mdc
