Skip to main content

Overview

The DragDropProvider component creates a context that enables drag and drop interactions for its children. It manages the drag and drop state and coordinates between draggable and droppable elements.

Basic Usage

Wrap your application or a section with DragDropProvider:

Event Handling

Listen to drag and drop events to respond to user interactions:

Multiple Contexts

You can create multiple independent drag and drop contexts:

Configuration

Customize behavior with plugins, sensors, and modifiers. Each accepts either an array (which replaces the defaults) or a function that receives the defaults.

Extending defaults

Use the function form to add to or configure the defaults without replacing them:

Replacing defaults

Pass an array to fully replace the defaults:

API Reference

Props

ReactNode
required
Content where drag and drop should be enabled.
DragDropManager
Optional custom manager instance. If not provided, one will be created.

Events

(event: BeforeDragStartEvent, manager: DragDropManager) => void
Called before dragging starts. Call event.preventDefault() to cancel.
(event: DragStartEvent, manager: DragDropManager) => void
Called when dragging begins.
(event: DragMoveEvent, manager: DragDropManager) => void
Called when the dragged element moves.
(event: DragOverEvent, manager: DragDropManager) => void
Called when dragging over a droppable target. Call event.preventDefault() to prevent the default behavior of plugins that respond to this event.
(event: DragEndEvent, manager: DragDropManager) => void
Called when dragging ends, whether dropped on a target or not.
(event: CollisionEvent, manager: DragDropManager) => void
Called when collisions are detected. Call event.preventDefault() to prevent automatic target selection.

Event object structure

All event handlers receive an event object and the manager instance. The most commonly used event, onDragEnd, has this shape:
For sortable elements, use the isSortable type guard to access sortable-specific properties:

Configuration

Sensor[] | (defaults: Sensor[]) => Sensor[]
Sensors for detecting user input. Pass an array to replace defaults, or a function to extend them.
Plugin[] | (defaults: Plugin[]) => Plugin[]
Plugins to extend functionality. Pass an array to replace defaults, or a function to extend them.
Modifier[] | (defaults: Modifier[]) => Modifier[]
Modifiers to customize drag behavior. Pass an array to replace defaults, or a function to extend them.