|
| 1 | +The Accessibility module provides WCAG 2.1 AA compliance features that are automatically initialized when AdminLTE loads. |
| 2 | + |
| 3 | +##### Features |
| 4 | + |
| 5 | +| Feature | WCAG Criterion | Description | |
| 6 | +|---------|---------------|-------------| |
| 7 | +| Skip Links | 2.4.1 Bypass Blocks | Adds "Skip to main content" and "Skip to navigation" links. | |
| 8 | +| Focus Management | 2.4.3 & 2.4.7 | Tab cycling, focus trapping in modals, and focus restoration. | |
| 9 | +| Keyboard Navigation | 2.1.1 Keyboard | Arrow key navigation in menus, Enter/Space for custom buttons. | |
| 10 | +| Reduced Motion | 2.3.3 Animation | Respects `prefers-reduced-motion` by disabling animations. | |
| 11 | +| Live Announcements | 4.1.3 Status Messages | Announces errors and success messages to screen readers. | |
| 12 | +| Error Identification | 3.3.1 & 3.3.2 | Auto-labels unlabelled inputs, announces form validation errors. | |
| 13 | +| Table Accessibility | 1.3.1 Info & Relationships | Adds `scope` attributes to table headers automatically. | |
| 14 | + |
| 15 | +##### Configuration |
| 16 | + |
| 17 | +The module is initialized in `adminlte.ts` with all features enabled by default: |
| 18 | + |
| 19 | +```js |
| 20 | +initAccessibility({ |
| 21 | + announcements: true, |
| 22 | + skipLinks: true, |
| 23 | + focusManagement: true, |
| 24 | + keyboardNavigation: true, |
| 25 | + reducedMotion: true |
| 26 | +}) |
| 27 | +``` |
| 28 | + |
| 29 | +Set any option to `false` to disable that feature. |
| 30 | + |
| 31 | +##### Public API |
| 32 | + |
| 33 | +```js |
| 34 | +import { initAccessibility } from 'admin-lte' |
| 35 | + |
| 36 | +const a11y = initAccessibility() |
| 37 | + |
| 38 | +// Announce a message to screen readers |
| 39 | +a11y.announce('Item saved successfully', 'polite') |
| 40 | +a11y.announce('Form has errors', 'assertive') |
| 41 | + |
| 42 | +// Focus a specific element |
| 43 | +a11y.focusElement('#my-input') |
| 44 | + |
| 45 | +// Trap focus inside a container (useful for custom modals/dialogs) |
| 46 | +a11y.trapFocus(document.querySelector('.my-dialog')) |
| 47 | + |
| 48 | +// Add semantic landmarks to the page |
| 49 | +a11y.addLandmarks() |
| 50 | +``` |
| 51 | + |
| 52 | +##### Utility Functions |
| 53 | + |
| 54 | +```js |
| 55 | +import { accessibilityUtils } from 'admin-lte' |
| 56 | + |
| 57 | +// Check color contrast ratio (WCAG 1.4.3) |
| 58 | +const result = accessibilityUtils.checkColorContrast('rgb(0,0,0)', 'rgb(255,255,255)') |
| 59 | +// { ratio: 21, passes: true } |
| 60 | + |
| 61 | +// Check if an element is focusable |
| 62 | +accessibilityUtils.isFocusable(element) |
| 63 | + |
| 64 | +// Generate a unique ID for ARIA attributes |
| 65 | +accessibilityUtils.generateId('modal') // "modal-x7k2m9p4q" |
| 66 | +``` |
| 67 | + |
| 68 | +##### CSS Classes |
| 69 | + |
| 70 | +| Class | Description | |
| 71 | +|-------|-------------| |
| 72 | +| `skip-links` | Container for skip navigation links. | |
| 73 | +| `skip-link` | Individual skip link, visible only on focus. | |
| 74 | +| `reduce-motion` | Added to `<body>` when user prefers reduced motion. | |
| 75 | +| `sr-only` | Screen reader only content (visually hidden). | |
| 76 | +| `live-region` | ARIA live region for dynamic announcements. | |
| 77 | + |
| 78 | +##### Notes |
| 79 | + |
| 80 | +- The module integrates with Bootstrap's modal and dropdown events for focus management. |
| 81 | +- Modal Escape key handling is deferred to Bootstrap to respect `keyboard: false` and stacked modals. |
| 82 | +- Form validation announcements work automatically for any input with HTML5 validation attributes. |
0 commit comments