DragDropManager is the heart of dnd-kit. It coordinates all aspects of drag and drop operations, manages entities, handles collisions, and provides the API for controlling drag operations.
Overview
Every drag and drop context requires a manager instance. The manager:- Maintains a registry of draggable and droppable entities
- Coordinates sensors for input handling
- Manages the current drag operation state
- Computes collisions between draggables and droppables
- Applies modifiers to transform coordinates
- Orchestrates plugins for extended functionality
- Emits events for monitoring drag operations
Creating a manager
Basic usage
- Sensors:
PointerSensor,KeyboardSensor - Plugins:
Accessibility,AutoScroller,Cursor,Feedback,PreventSelection - Modifiers: None by default
Custom configuration
You can customize the manager by providing configuration options:Configuration options accept either a value (replaces defaults) or a function that receives defaults (allows extending).
Type signature
Configuration options
Sensors
Sensors detect and handle user input:Plugins
Plugins extend functionality:Modifiers
Modifiers transform drag coordinates:Renderer
The renderer handles visual updates:requestAnimationFrame. You can provide a custom renderer for framework integration:
Core properties
Actions
Theactions property provides methods to control drag operations:
Registry
Theregistry manages all draggable and droppable entities:
Drag operation
ThedragOperation property holds the current operation state:
Monitor
Themonitor emits events during drag operations:
Collision observer
ThecollisionObserver computes and manages collisions:
Customizable configuration
TheCustomizable<T> type allows flexible configuration:
As a value (replaces defaults)
As a function (receives defaults)
Filtering defaults
DOM implementation
The@dnd-kit/dom package extends the abstract manager with DOM-specific features:
ScrollListener: Tracks scroll position changesScroller: Manages scroll offsets during dragStyleInjector: Injects required CSS styles
Default preset
The default configuration provides sensible defaults:Lifecycle management
Cleanup
Always clean up the manager when you’re done:destroy() method:
- Stops any active drag operation
- Unregisters all entities
- Cleans up all sensors
- Destroys all plugins and modifiers
- Removes event listeners
Framework integration
Framework adapters handle lifecycle automatically:Type inference
The manager’s generic types flow through the entire system:Related
DragDropManager API
Complete API reference
Sensors
Input detection
Plugins
Extend functionality
Collision detection
Detect overlaps