Layered design
The architecture consists of three main layers:Abstract core layer
The@dnd-kit/abstract package provides the foundational abstractions and business logic:
- DragDropManager: Central orchestrator for drag and drop operations
- Entity system: Base classes for
DraggableandDroppableentities - Sensor architecture: Abstract base class for input handling
- Collision detection: Priority-based collision system
- Plugin system: Extensibility through plugins
- Modifier system: Coordinate transformation pipeline
The abstract layer is framework-agnostic and has no DOM dependencies. You typically won’t use this package directly unless you’re building a custom implementation layer.
DOM implementation layer
The@dnd-kit/dom package builds on the abstract core and adds DOM-specific functionality:
- Concrete implementations: DOM-based
DraggableandDroppableclasses - Input sensors:
PointerSensor(mouse/touch/pen) andKeyboardSensor - DOM plugins: Visual feedback, accessibility, auto-scrolling, cursor management
- Utilities: DOM helpers for positioning, transforms, and scrolling
- Sortable primitives: Higher-level sorting abstractions
Framework adapter layer
Framework-specific packages (@dnd-kit/react, @dnd-kit/vue, etc.) provide idiomatic APIs:
- Framework integration: Hooks, composables, or components
- Reactive bindings: Integration with framework reactivity systems
- Lifecycle management: Automatic setup and cleanup
- Type safety: Framework-specific type definitions
Core concepts
Entities
Entities represent the fundamental units in the drag and drop system:- Draggable: Entities that can be dragged
- Droppable: Entities that can receive dragged items
Manager
TheDragDropManager orchestrates all drag and drop operations:
Reactive state
The library uses the@dnd-kit/state package for fine-grained reactivity:
- Signals: Primitive reactive values
- Derived values: Computed from other reactive values
- Effects: Side effects that run when dependencies change
- Batching: Multiple updates in a single transaction
Data flow
Here’s how data flows through the system during a drag operation:- User interaction: Sensor detects pointer/keyboard input
- Activation: Sensor validates constraints and starts drag
- Manager actions:
actions.start()initializes the operation - State updates:
dragOperationupdates with source, position, shape - Collision detection:
collisionObservercomputes intersections - Target updates:
dragOperation.targetset to collision winner - Modifier pipeline: Coordinates transformed by active modifiers
- Plugin reactions: Plugins respond to state changes (feedback, scrolling)
- Movement:
actions.move()updates position as user drags - Completion:
actions.stop()ends operation, fires events
Extension points
The architecture provides multiple extension points:Sensors
Create custom input methods by extending theSensor base class:
Plugins
Add features by extending thePlugin base class:
Modifiers
Transform coordinates by extending theModifier base class:
Collision detectors
Implement custom collision algorithms:Package structure
The monorepo is organized into focused packages:- @dnd-kit/abstract: Core abstractions
- @dnd-kit/dom: DOM implementation
- @dnd-kit/react: React adapter
- @dnd-kit/state: Reactive state primitives
- @dnd-kit/geometry: Spatial utilities (shapes, coordinates)
- @dnd-kit/helpers: Shared utilities
Type safety
The library is built with TypeScript and provides comprehensive type definitions:Next steps
DragDropManager
Learn about the central manager class
Draggables and Droppables
Understand the entity system
Sensors
Explore input handling
Plugins
Extend functionality with plugins