DragOverlay is a component that renders custom content during drag operations. It provides a visual representation of the dragged item that follows the cursor, separate from the original element.
Usage
Props
The content to render in the overlay. Can be a static React node or a function that receives the drag source and returns content.
Customize or disable the drop animation that plays when a drag operation ends.
undefined— Use the default animation (250ms ease)null— Disable the drop animation entirely{duration, easing}— Customize the animation timing(context) => Promise<void> | void— Provide a fully custom animation function
CSS class name to apply to the overlay container element.
Inline styles to apply to the overlay container element.
HTML tag name for the overlay container element.
Whether the overlay is disabled. Can be a boolean or a function that receives the drag source.
Examples
Basic Overlay
Dynamic Overlay Content
Custom Drop Animation
Overlay with No Animation
Conditional Overlay
Styled Overlay with Shadow
Multiple Overlays for Different Types
Overlay with Item Count
Type Safety
Use TypeScript generics to type the drag source:Behavior
- The overlay is automatically positioned to follow the cursor during drag operations
- Children inside the overlay cannot register themselves as draggables or droppables (the manager registry is patched)
- The overlay element has a
data-dnd-overlayattribute for styling purposes - When the overlay is disabled or there’s no active drag, the overlay renders nothing
Related
- DragDropProvider — Context provider for drag and drop
- useDraggable — Make elements draggable
- Feedback Plugin — Built-in plugin that powers the overlay