Skip to main content

Accessibility Features in Action

The dnd-kit Accessibility plugin automatically enhances drag and drop interfaces with comprehensive keyboard support, screen reader announcements, and ARIA attributes. This guide demonstrates how to leverage these features.

The Accessibility Plugin

The Accessibility plugin provides:
  • Automatic ARIA attributes for draggable elements
  • Live region announcements for screen readers
  • Hidden text instructions for keyboard users
  • Proper focus management
  • Debounced updates to prevent announcement spam

Basic Setup

packages/dom/src/core/plugins/accessibility/Accessibility.ts
That’s it! The plugin automatically adds all necessary accessibility features.

Default Screen Reader Instructions

The plugin provides default instructions that are read to screen reader users:
packages/dom/src/core/plugins/accessibility/defaults.ts

Custom Screen Reader Instructions

Provide custom instructions tailored to your interface:

Custom Announcements

The plugin announces key events to screen readers. Customize these announcements:
packages/dom/src/core/plugins/accessibility/defaults.ts

Automatic ARIA Attributes

The Accessibility plugin automatically adds and manages these attributes:
packages/dom/src/core/plugins/accessibility/defaults.ts

Example: Accessible Sortable List

Debouncing Announcements

By default, dragover and dragmove events are debounced to prevent overwhelming screen readers:
packages/dom/src/core/plugins/accessibility/Accessibility.ts

Example: Accessible Kanban Board

Custom ID Prefixes

Customize the IDs used for accessibility elements:
packages/dom/src/core/plugins/accessibility/Accessibility.ts

Best Practices

  1. Provide meaningful labels: Use aria-label on draggable elements to give them descriptive names.
  2. Include context in announcements: Tell users where items are and where they’re going, not just what’s happening.
  3. Test with real screen readers: Test with NVDA, JAWS, or VoiceOver to ensure announcements are clear.
  4. Keep announcements concise: Screen reader users appreciate brevity.
  5. Use the KeyboardSensor: Always include the KeyboardSensor for keyboard-only users.
  6. Test keyboard navigation: Ensure all functionality works with keyboard alone.
  7. Provide visual focus indicators: CSS focus styles are critical for keyboard users.
  8. Consider announcement frequency: Use the debounce option to prevent overwhelming users during rapid movements.

Safari Compatibility

The plugin automatically handles Safari’s unique requirements, ensuring elements are properly focusable even in Safari.

Live Region Implementation

The plugin creates a visually hidden live region for announcements:
packages/dom/src/core/plugins/accessibility/Accessibility.ts
This ensures screen readers announce updates immediately without interrupting other content.