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
ReactNode | ((source: Draggable) => ReactNode)
required
The content to render in the overlay. Can be a static React node or a function that receives the drag source and returns content.
DropAnimation | null
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
string
CSS class name to apply to the overlay container element.
React.CSSProperties
Inline styles to apply to the overlay container element.
string
default:"div"
HTML tag name for the overlay container element.
boolean | ((source: Draggable | null) => boolean)
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