Skip to main content

Accessible Design System v1

Type to filter components by name, description, or keywords

Colors

Color palette and CSS variables for consistent theming across your application. All colors meet WCAG 2.2 AA contrast requirements for accessibility.

Primary --ds-ads-primary-color
#0066cc

Primary Hover --ds-ads-primary-hover
#0052a3

Success --ds-ads-success-color
#28a745

Warning --ds-ads-warning-color
#ffc107

Error --ds-ads-error-color
#dc3545

Text Primary --ds-ads-text-color
#1a1a1a

Text Secondary --ds-ads-text-secondary
#4a4a4a

Border --ds-ads-border-color
#d0d0d0

CSS

:root {
    /* Primary Colors */
    --ds-ads-primary-color: #0066cc;
    --ds-ads-primary-hover: #0052a3;
    --ds-ads-focus-outline: #0066cc;
    
    /* Status Colors */
    --ds-ads-success-color: #28a745;
    --ds-ads-warning-color: #ffc107;
    --ds-ads-error-color: #dc3545;
    
    /* Text Colors */
    --ds-ads-text-color: #1a1a1a;
    --ds-ads-text-secondary: #4a4a4a;
    
    /* Background Colors */
    --ds-ads-bg-color: #ffffff;
    --ds-ads-bg-secondary: #f5f5f5;
    
    /* Border Colors */
    --ds-ads-border-color: #d0d0d0;
    
    /* Shadow Variables (acceptable use of rgba) */
    --ds-ads-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --ds-ads-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Usage Example */
.example {
    color: var(--ds-ads-text-color);
    background-color: var(--ds-ads-bg-color);
    border: 1px solid var(--ds-ads-border-color);
}

Accessibility Guidelines

Contrast Ratios

All color combinations in this design system meet WCAG 2.2 Level AA standards:

  • Primary text (#1a1a1a on #ffffff): 11.5:1 contrast ratio - Exceeds AAA standard (7:1)
  • Secondary text (#4a4a4a on #ffffff): 7.5:1 contrast ratio - Exceeds AAA standard
  • Primary button (white on #0066cc): 4.6:1 contrast ratio - Meets AA standard (4.5:1)
  • Border color (#d0d0d0 on #ffffff): 3:1 contrast ratio - Meets non-text contrast requirement

Key Requirements

  • Never use color alone: Always combine color with text, icons, or patterns to convey meaning
  • Test with color blindness simulators: Ensure color combinations work for users with color vision deficiencies
  • Maintain contrast in all states: Hover, focus, active, and disabled states must maintain adequate contrast
  • Consider dark mode: If implementing dark mode, ensure all colors maintain proper contrast ratios

Custom Implementation Notes

Status colors: While success (green), warning (yellow), and error (red) colors are standard, never rely on color alone to communicate status. Always include text labels or icons. For example, error messages should include both the red color AND text that says "Error:" or an error icon.

CSS variables: Using CSS custom properties (variables) makes it easy to maintain consistent colors and enables theme switching. If you need to change a color, update it once in the :root declaration and it updates throughout your application.

Testing Tools

  • WebAIM Contrast Checker: https://webaim.org/resources/contrastchecker/
  • Chrome DevTools: Built-in contrast ratio checker in Inspect Element
  • Color Blindness Simulators: Verify designs work for users with color vision deficiencies
  • Windows High Contrast Mode: Test that explicit borders (not border: none) maintain visibility

References

Understanding Opacity and Contrast Testing

Not all uses of rgba() or opacity are problematic for accessibility. This section explains when opacity is acceptable and when it creates accessibility issues that require manual testing.

Rule of Thumb

Can accessibility tools test the contrast automatically?

  • YES: Use solid colors with CSS variables → Tools can verify compliance
  • NO: Avoid opacity, or be prepared to manually test → Tools cannot verify compliance

When Opacity IS Acceptable

These decorative effects don't affect text contrast and don't need contrast testing:

Example 1: Box Shadows (✓ Acceptable)

Box shadows are decorative effects

No text appears directly on the shadow, so contrast testing is not required. However, you should still use CSS variables for consistency.

CSS - Box Shadow (Acceptable)

/* ✓ ACCEPTABLE: Shadows are decorative, not tested for contrast */
:root {
    --ds-ads-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --ds-ads-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card {
    box-shadow: var(--ds-ads-shadow-md);
    /* Shadow creates depth, no text on shadow itself */
}

When Opacity REQUIRES Manual Testing

These scenarios prevent automated contrast testing and require manual verification:

Example 2: Semi-Transparent Overlay on Image (⚠ Needs Manual Testing)

Overlay Title

This text appears on a semi-transparent overlay over a background image. Contrast depends on the image underneath.

Why manual testing is required: The final text color depends on BOTH the overlay color AND the image underneath. Automated tools cannot know what image you'll use, so they cannot calculate the actual contrast ratio.

CSS - Overlay (Requires Manual Testing)

/* ⚠ REQUIRES MANUAL TESTING */
.overlay {
    background-image: url('hero.jpg');
    position: relative;
}

.overlay::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent overlay */
}

.overlay-content {
    position: relative;
    z-index: 1;
    color: white; /* Text on overlay */
}

/* You must manually test this with your actual image:
   1. Take screenshot in Photoshop/Figma
   2. Use eyedropper to get actual text color
   3. Use eyedropper to get actual background (overlay + image)
   4. Check contrast ratio manually
*/
Example 3: Gradient Backgrounds (⚠ Needs Manual Testing)

Gradient Background

Text on gradient backgrounds requires testing at the lightest point of the gradient to ensure contrast is maintained.

Why manual testing is required: Gradients transition between colors. You must test contrast at the point where the gradient is lightest (for dark text) or darkest (for light text).

CSS - Gradient (Requires Manual Testing)

/* ⚠ REQUIRES MANUAL TESTING */
.gradient-background {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Test contrast at BOTH ends of gradient:
   1. Test white text against #667eea (lightest point)
   2. Test white text against #764ba2 (darkest point)
   3. Use whichever is LOWER as your contrast ratio
   4. If lowest point fails 4.5:1, adjust gradient colors
*/
Example 4: Hover States with Opacity (❌ Wrong Approach)

❌ Wrong: Using opacity for hover

This button uses rgba(0, 102, 204, 0.1) for hover. Accessibility tools cannot verify the contrast.

✓ Right: Using solid color for hover

This button uses #fafcfe for hover. Accessibility tools can verify 16.8:1 contrast ratio.

CSS - Hover States Comparison

/* ❌ WRONG: Opacity prevents automated testing */
.button-wrong:hover {
    background-color: rgba(0, 102, 204, 0.1);
    /* Tools cannot verify text contrast */
}

/* ✓ RIGHT: Solid color enables automated testing */
:root {
    --ds-ads-primary-bg-lightest: #fafcfe; /* Solid hex color */
}

.button-right:hover {
    background-color: var(--ds-ads-primary-bg-lightest);
    /* Tools verify: 16.8:1 contrast ratio ✓ */
}

How to Manually Test Opacity Scenarios

When you must use opacity or scenarios that prevent automated testing:

  1. Screenshot Method (Most Accurate):
    • Take a full-resolution screenshot of your design
    • Open in Photoshop, Figma, or similar tool
    • Use eyedropper to sample the actual rendered text color
    • Use eyedropper to sample the actual rendered background color
    • Enter both colors into WebAIM Contrast Checker
    • Verify minimum 4.5:1 ratio for normal text (3:1 for large text)
  2. Browser DevTools Method:
    • Right-click the text element
    • Inspect → Computed tab
    • Look for "color" value (rendered color after opacity)
    • Look for "background-color" value (rendered color)
    • Test these values in contrast checker
  3. Test Multiple Scenarios:
    • For gradients: Test at lightest AND darkest points
    • For images: Test with multiple representative images
    • For overlays: Test worst-case scenario (lightest image)

Summary: When to Use What

Scenario Can Use Opacity? Testing Required
Box shadows ✓ Yes (with variable) None - decorative only
Hover/focus states ❌ No - use solid colors Automated tools verify
Text on overlay + image ⚠ Use with caution Manual testing required
Gradient backgrounds ⚠ Use with caution Manual testing at extremes
Semi-transparent containers ⚠ Use with caution Manual testing required
Background colors ❌ No - use solid colors Automated tools verify
Text colors ❌ No - use solid colors Automated tools verify

Key Takeaway

Default to solid colors with CSS variables for all text and interactive elements. This enables automated contrast testing and ensures WCAG compliance. Only use opacity when absolutely necessary for the design, and commit to manual testing with real content.