Skip to main content
The useDraggable hook makes an element draggable. It registers the element with the drag and drop manager, attaches sensors, and provides reactive state about the drag status.

Usage

Parameters

string | number
required
Unique identifier for this draggable element. Used to track the element during drag operations.
Element | RefObject<Element>
The DOM element to make draggable. If not provided, use the ref from the return value.
Element | RefObject<Element>
A specific element to use as the drag handle. If provided, dragging can only be initiated from this element.
T
Custom data to attach to this draggable. Accessible during drag operations and in event handlers.
boolean
default:"false"
Whether this draggable is disabled. Disabled draggables cannot be dragged.
Sensor[]
Override the sensors for this specific draggable. By default, inherits from DragDropProvider.
Modifier[]
Modifiers that transform the position during drag. Applied in addition to provider-level modifiers.
Plugin[]
Plugins specific to this draggable. Applied in addition to provider-level plugins.
{x: number, y: number}
Alignment point for the drag source, relative to the element’s position. Values are percentages (0-1).

Return Value

(element: Element | null) => void
Callback ref to attach to the draggable element.
(element: Element | null) => void
Callback ref to attach to a drag handle element.
Draggable<T>
The underlying Draggable instance. Access this for advanced use cases.
boolean
Whether this element is currently being dragged.
boolean
Whether this element is in the dropping animation phase (after release, before settling).
boolean
Whether this element is the source of the current drag operation (true during dragging and dropping).

Examples

Basic Draggable

Draggable with Custom Data

Draggable with Handle

Conditionally Disabled

With Custom Modifiers

Type Safety

Use TypeScript generics to type the custom data: