Overview
The vanilla JavaScript adapter provides framework-agnostic drag and drop functionality through the core@dnd-kit/dom package. Use this when you’re building without a framework or want direct control over the DOM.
Installation
Install the core packages:Getting Started
Complete Example
Here’s a full working example:Sortable Lists
Create sortable lists using theSortable class:
Advanced Features
Custom Drag Handles
Specify a different element as the drag handle:Modifiers
Apply modifiers to constrain or modify drag behavior:Sensors
Customize how drag operations are initiated:Type Safety
Add type safety to your drag and drop data:Cleanup
Always destroy the manager when you’re done:Best Practices
- Initialize once: Create your
DragDropManagerinstance once and reuse it - Clean up: Always call
destroy()to prevent memory leaks - Use data property: Store metadata on draggables for easier event handling
- Batch updates: Apply multiple changes together for better performance
- Element references: Keep element references up to date when DOM changes
Next Steps
Sensors
Configure how drag operations are initiated
Modifiers
Constrain and modify drag behavior
Collision Detection
Control how droppable targets are detected
Events
Listen to all available drag and drop events