Skip to main content

Overview

Component Library is built with accessibility as a core principle. All components follow WCAG 2.1 AA guidelines and include proper ARIA attributes.

Key Features

ARIA Attributes

Proper ARIA labels, roles, and states

Keyboard Navigation

Full keyboard support for all interactive elements

Screen Readers

Optimized for screen reader compatibility

Color Contrast

WCAG AA compliant color contrast ratios

ARIA Attributes

Button Component

// Icon-only button with accessible label
<Button aria-label="Close dialog">
  ×
</Button>

// Button with description
<Button aria-describedby="save-description">
  Save
</Button>
<span id="save-description" className="sr-only">
  Save your changes to the document
</span>

Input Component

// Automatic ARIA attributes
<Input
  label="Email"
  required
  error={hasError}
  errorMessage="Invalid email"
  helperText="We'll never share your email"
/>

// Generates:
// - aria-required="true"
// - aria-invalid="true" (when error)
// - aria-describedby="email-error email-helper"

Keyboard Navigation

Button

KeyAction
EnterActivates button
SpaceActivates button
TabMoves focus to button

Input

KeyAction
TabMoves focus to input
Shift + TabMoves focus to previous element
All typing keysEnters text

Focus Management

All components include visible focus indicators:
/* Automatic focus styles */
.btn:focus-visible {
  outline: 3px solid var(--focus-ring-color);
  outline-offset: 2px;
}

.input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--focus-ring-color);
}

Screen Reader Support

Semantic HTML

Components use semantic HTML elements:
// Button uses <button> element
<Button>Click me</Button>

// Input uses <input> with <label>
<Input label="Email" />

Hidden Text

Use the sr-only class for screen reader-only text:
<Button>
  <TrashIcon />
  <span className="sr-only">Delete item</span>
</Button>

Color Contrast

All components meet WCAG AA standards:
  • Normal text: 4.5:1 contrast ratio
  • Large text: 3:1 contrast ratio
  • Interactive elements: 3:1 contrast ratio

Testing Contrast

// Primary button (white on blue)
// Contrast ratio: 4.6:1 ✓

// Error text (red on white)
// Contrast ratio: 4.5:1 ✓

Form Accessibility

Labels

Always provide labels for inputs:
// ✅ Good
<Input label="Email" type="email" />

// ❌ Bad
<input type="email" placeholder="Email" />

Error Messages

Error messages are announced to screen readers:
<Input
  label="Email"
  error={true}
  errorMessage="Please enter a valid email"
  // Generates role="alert" for screen readers
/>

Required Fields

Indicate required fields visually and programmatically:
<Input
  label="Email"
  required
  // Adds asterisk (*) and aria-required="true"
/>

Testing Accessibility

Automated Testing

Use Storybook’s accessibility addon:
  1. Open Storybook
  2. Navigate to a component
  3. Check the “Accessibility” tab
  4. Review violations and warnings

Manual Testing

  • Tab through all interactive elements
  • Verify focus indicators are visible
  • Test Enter/Space on buttons
  • Test with NVDA (Windows) or VoiceOver (Mac)
  • Verify all content is announced
  • Check form labels and errors
  • Use browser DevTools
  • Check contrast ratios
  • Test in different color modes
  • Test at 200% zoom
  • Verify layout doesn’t break
  • Check text remains readable

Best Practices

Always provide aria-label for icon-only buttons
Use semantic HTML elements (button, input, label)
Ensure sufficient color contrast (4.5:1 for text)
Test with keyboard navigation
Provide visible focus indicators
Don’t rely solely on color to convey information
Don’t remove focus outlines without providing alternatives

Resources