Accessibility
Soft UI is built with accessibility as a core principle. All components follow WCAG 2.1 Level AA standards and implement ARIA patterns from Base UI.Base UI Foundation
Soft UI components are built on Base UI primitives, which provide:- Complete ARIA patterns - All components have proper roles, states, and properties
- Keyboard navigation - Full keyboard support out of the box
- Focus management - Automatic focus trapping and restoration
- Screen reader announcements - Live regions and semantic markup
Focus Ring Implementation
Soft UI uses a dual-ring focus indicator for maximum visibility.Focus Ring Utilities
Frompackages/tokens/src/utilities.css:185-194:
CSS Variables
--color-utility-focus-inner- 1px inner ring (high contrast)--color-utility-focus-outer- 3px outer ring (brand color with opacity)
Implementation Pattern
Frompackages/react/src/components/button.tsx:56-57:
Custom Component Focus Rings
Keyboard Navigation
All interactive components support keyboard navigation.Standard Keyboard Patterns
| Component | Keys | Behavior |
|---|---|---|
| Button | Enter, Space | Activate button |
| Dialog | Escape | Close dialog |
| Menu | ↑ ↓ | Navigate items |
| Menu | Enter, Space | Select item |
| Menu | Escape | Close menu |
| Tabs | ← → | Navigate tabs |
| Tabs | Home, End | First/last tab |
| Select | ↑ ↓ | Navigate options |
| Select | Enter, Space | Open/select |
| Combobox | ↑ ↓ | Navigate options |
| Combobox | Enter | Select option |
| Combobox | Escape | Close dropdown |
| Slider | ← → | Adjust value |
| Slider | Home, End | Min/max value |
| Checkbox | Space | Toggle checked |
| Radio | ↑ ↓ ← → | Navigate options |
| Switch | Space | Toggle on/off |
Example: Tab Navigation
ARIA Patterns
Data Attributes
Base UI components use data attributes for state management. These automatically provide ARIA attributes.Common Data Attributes
Real Example: Select Component
Required ARIA Labels
Some components require explicit labels for screen readers.Icon-Only Buttons
Custom Interactive Elements
Live Regions
For dynamic content updates, use ARIA live regions.Toast Notifications
Custom Live Region
Screen Reader Considerations
Semantic HTML
Use semantic HTML elements for better screen reader support:Visually Hidden Content
Use thesr-only utility class for screen reader-only content:
Descriptive Labels
Provide context for screen reader users:Focus Management
Focus Trapping
Modals and dialogs automatically trap focus:Manual Focus Management
Skip to Content Links
Color Contrast
All Soft UI color tokens meet WCAG 2.1 Level AA contrast requirements:- Normal text: Minimum 4.5:1 contrast ratio
- Large text: Minimum 3:1 contrast ratio
- UI components: Minimum 3:1 contrast ratio
Text Colors
Testing Contrast
Use browser DevTools or tools like:Motion & Animation
Respect user motion preferences:Form Accessibility
Field Component
Use theField component for accessible form inputs:
- Proper
<label>association viahtmlFor aria-describedbyfor descriptions and errorsaria-invalidwhen error is present
Error Announcements
Testing Accessibility
Automated Testing
Use tools like:Manual Testing
-
Keyboard Navigation
- Tab through all interactive elements
- Verify focus indicators are visible
- Test all keyboard shortcuts
-
Screen Reader Testing
- Test with NVDA (Windows) or VoiceOver (macOS)
- Verify all content is announced
- Check heading hierarchy
-
Color Contrast
- Test in light and dark modes
- Verify all states (hover, focus, disabled)
- Check with color blindness simulators
Best Practices
- Use semantic HTML - Prefer
<button>over<div onClick> - Provide labels - All form inputs and icon buttons need labels
- Maintain focus visibility - Never remove focus outlines without a replacement
- Test with keyboard - Ensure all functionality is keyboard accessible
- Respect user preferences - Honor reduced motion and high contrast settings
- Use ARIA sparingly - Rely on semantic HTML first, ARIA as enhancement
- Test with screen readers - Automated tools miss many issues