0Pricing
React Academy · Lesson

dnd-kit Architecture and Accessibility-First Design

Understand dnd-kit's sensor model, accessibility announcements, and how it differs from react-beautiful-dnd.

dnd-kit Architecture and Accessibility-First Design is a free React Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the React Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why dnd-kit Replaced react-beautiful-dnd

react-beautiful-dnd was the go-to drag-and-drop library for React, but it was officially archived in 2023 and is no longer maintained. The community quickly rallied around dnd-kit as the recommended replacement, which was designed from scratch with modern React and accessibility in mind.

dnd-kit Core Architecture

dnd-kit is built around three key architectural concepts: DndContext manages all drag state and coordinates between draggable and droppable elements, sensors abstract input methods so the same drag logic works for mouse, touch, and keyboard, and modifiers let you snap, restrict, or transform the drag movement.

Sensors: Input Abstraction

dnd-kit ships with three built-in sensors. PointerSensor handles both mouse and touch input through the unified Pointer Events API. KeyboardSensor enables full keyboard-only drag and drop. TouchSensor handles legacy touch events. You configure sensors via the sensors prop on DndContext.

Keyboard Drag and Drop Instructions

dnd-kit has built-in keyboard navigation for accessibility. Users press Space to pick up an item, Arrow keys to move it to a new position, Space again to drop it, and Escape to cancel the drag without making changes. These interactions are announced to screen readers automatically.

ARIA and Screen Reader Support

dnd-kit automatically applies aria-grabbed to draggable items to indicate their grab state to assistive technologies. It uses aria-dropeffect on droppable zones to communicate what will happen when an item is dropped. A live region announces status updates so screen reader users hear confirmations like "Item picked up" or "Item dropped successfully."

Tree-Shakable and CSS-Free Design

dnd-kit is designed to be tree-shakable, meaning you only import the pieces you actually use. There is no bundled CSS — all visual styling is your responsibility, giving you full control over the appearance of draggable elements, overlays, and drop zones. This keeps bundle sizes minimal.

DndContext Event Callbacks

DndContext provides three primary event callbacks for tracking the drag lifecycle. onDragStart fires when the user begins dragging and receives the active item ID. onDragOver fires continuously as the dragged item moves over droppable targets. onDragEnd fires when the drag completes, giving you the active item and the drop target.

Configuring Sensors on DndContext

You pass an array of sensor configurations to DndContext using the sensors prop combined with the useSensors hook. Each sensor is initialized with useSensor(SensorClass, options). For example, you can configure PointerSensor with a minimum drag distance to prevent accidental drags when clicking.

Modifiers for Movement Constraints

Modifiers transform the drag coordinates before they are applied to the dragged element. restrictToVerticalAxis locks movement to a single direction. restrictToParentElement keeps the dragged item within its container. snapCenterToCursor snaps the element so its center tracks the cursor. You compose multiple modifiers in an array.

Droppable and Draggable ID System

Every draggable and droppable element needs a unique string or number ID. These IDs are the primary way dnd-kit tracks what is being dragged and where it is being dropped. In onDragEnd, you read event.active.id for the dragged item and event.over?.id for the drop target to update your application state.

Accessibility-First Philosophy

Unlike many DnD libraries that treat keyboard support as an afterthought, dnd-kit puts accessibility at the core of its design. The KeyboardSensor is a first-class citizen with the same capabilities as PointerSensor. All ARIA attributes are managed automatically, and custom announcements can be configured via the accessibility prop on DndContext.

Keyboard Sensor Check

Which key does dnd-kit use to cancel an in-progress keyboard drag without making changes?

Lesson Recap: dnd-kit Foundations

dnd-kit replaced the archived react-beautiful-dnd as the community standard for React drag and drop. Its architecture centers on DndContext for state, sensors for input abstraction (Pointer, Keyboard, Touch), and modifiers for movement constraints. Accessibility is first-class: ARIA attributes, live region announcements, and full keyboard navigation are built in.

Frequently asked questions

Is the “dnd-kit Architecture and Accessibility-First Design” lesson free?

Yes — the full text of “dnd-kit Architecture and Accessibility-First Design” is free to read here on the web, and the React Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the React Academy course, upgrade to CoddyKit PRO.

What will I learn in “dnd-kit Architecture and Accessibility-First Design”?

Understand dnd-kit's sensor model, accessibility announcements, and how it differs from react-beautiful-dnd. You practise React Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start React Academy?

No prior experience is required. React Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “dnd-kit Architecture and Accessibility-First Design” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this React Academy lesson?

Yes. Every React Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. dnd-kit Architecture and Accessibility-First Design
  2. DndContext, useDraggable, and useDroppable
  3. SortableContext for Reorderable Lists
  4. Custom Drag Overlays and Multi-Container DnD
← Back to React Academy