useDroppable hook creates a drop target that can receive draggable elements. It registers the element with the drag and drop manager and provides reactive state about whether it’s being targeted.
Usage
Parameters
string | number
required
Unique identifier for this droppable element. Used to track the element during drag operations.
Element | RefObject<Element>
The DOM element to make droppable. If not provided, use the
ref from the return value.T
Custom data to attach to this droppable. Accessible in event handlers when elements are dropped.
boolean
default:"false"
Whether this droppable is disabled. Disabled droppables cannot receive drops.
string | string[]
Type or types of draggables this droppable accepts. If not specified, accepts all types.
string
Type identifier for this droppable. Can be used with collision detection or custom logic.
CollisionDetector
Custom collision detection algorithm for this droppable. Defaults to
defaultCollisionDetection.Return Value
(element: Element | null) => void
Callback ref to attach to the droppable element.
Droppable<T>
The underlying
Droppable instance. Access this for advanced use cases.boolean
Whether this element is currently the target of an active drag operation.
Examples
Basic Drop Zone
Droppable with Type Restrictions
Droppable with Custom Data
Nested Droppables
Multiple Drop Zones with Accept Types
Droppable List
Type Safety
Use TypeScript generics to type the custom data:Related
- DragDropProvider — Context provider for drag and drop
- useDraggable — Make elements draggable
- useSortable — Combine draggable and droppable