Title: Draggable
Published: March 9, 2021
Last modified: October 14, 2026

---

# Draggable

## In this article

 * [Props](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#props)
    - [appendToOwnerDocument: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#appendtoownerdocument-boolean)
    - [elementId: string](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#elementid-string)
    - [onDragEnd: ( event: DragEvent ) => void](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#ondragend-event-dragevent-void)
    - [onDragOver: ( event: DragEvent ) => void](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#ondragover-event-dragevent-void)
    - [onDragStart: ( event: DragEvent ) => void](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#ondragstart-event-dragevent-void)
    - [transferData: unknown](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#transferdata-unknown)
 * [Usage](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#usage)

`Draggable` is a Component that provides a way to set up a cross-browser (including
IE) customizable drag image and the transfer data for the drag event. It decouples
the drag handle and the element to drag: use it by wrapping the component that will
become the drag handle and providing the DOM ID of the element to drag.

Note that the drag handle needs to declare the `draggable="true"` property and bind
the `Draggable`s `onDraggableStart` and `onDraggableEnd` event handlers to its own`
onDragStart` and `onDragEnd` respectively. `Draggable` takes care of the logic to
setup the drag image and the transfer data, but is not concerned with creating an
actual DOM element that is draggable.

## 󠀁[Props](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#props)󠁿

The component accepts the following props:

### 󠀁[appendToOwnerDocument: boolean](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#appendtoownerdocument-boolean)󠁿

Whether to append the cloned element to the `ownerDocument` body. By default, elements
sourced by id are appended to the element’s wrapper.

 * Required: No
 * Default: `false`

### 󠀁[elementId: string](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#elementid-string)󠁿

The HTML id of the element to clone on drag.

 * Required: Yes

### 󠀁[onDragEnd: ( event: DragEvent ) => void](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#ondragend-event-dragevent-void)󠁿

A function called when dragging ends. This callback receives the `event` object 
from the `dragend` event as its first parameter.

 * Required: No
 * Default: `noop`

### 󠀁[onDragOver: ( event: DragEvent ) => void](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#ondragover-event-dragevent-void)󠁿

A function called when the element being dragged is dragged over a valid drop target.
This callback receives the `event` object from the `dragover` event as its first
parameter.

 * Required: No
 * Default: `noop`

### 󠀁[onDragStart: ( event: DragEvent ) => void](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#ondragstart-event-dragevent-void)󠁿

A function called when dragging starts. This callback receives the `event` object
from the `dragstart` event as its first parameter.

 * Required: No
 * Default: `noop`

### 󠀁[transferData: unknown](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#transferdata-unknown)󠁿

Arbitrary data object attached to the drag and drop event.

 * Required: Yes

## 󠀁[Usage](https://developer.wordpress.org/block-editor/reference-guides/components/draggable/?output_format=md#usage)󠁿

    ```language-jsx
    import { Draggable, Panel, PanelBody } from '@wordpress/components';
    import { Icon, more } from '@wordpress/icons';

    const MyDraggable = () => (
        <div id="draggable-panel">
            <Panel header="Draggable panel">
                <PanelBody>
                    <Draggable elementId="draggable-panel" transferData={ {} }>
                        { ( { onDraggableStart, onDraggableEnd } ) => (
                            <div
                                className="example-drag-handle"
                                draggable
                                onDragStart={ onDraggableStart }
                                onDragEnd={ onDraggableEnd }
                            >
                                <Icon icon={ more } />
                            </div>
                        ) }
                    </Draggable>
                </PanelBody>
            </Panel>
        </div>
    );
    ```

In case you want to call your own `dragstart` / `dragend` event handlers as well,
you can pass them to `Draggable` and it’ll take care of calling them after their
own:

    ```language-jsx
    import { Draggable, Panel, PanelBody } from '@wordpress/components';
    import { Icon, more } from '@wordpress/icons';

    const MyDraggable = ( { onDragStart, onDragEnd } ) => (
        <div id="draggable-panel">
            <Panel header="Draggable panel">
                <PanelBody>
                    <Draggable
                        elementId="draggable-panel"
                        transferData={ {} }
                        onDragStart={ onDragStart }
                        onDragEnd={ onDragEnd }
                    >
                        { ( { onDraggableStart, onDraggableEnd } ) => (
                            <div
                                className="example-drag-handle"
                                draggable
                                onDragStart={ onDraggableStart }
                                onDragEnd={ onDraggableEnd }
                            >
                                <Icon icon={ more } />
                            </div>
                        ) }
                    </Draggable>
                </PanelBody>
            </Panel>
        </div>
    );
    ```

First published

March 9, 2021

Last updated

October 14, 2026

Edit article

[ Improve it on GitHub: Draggable ](https://github.com/WordPress/gutenberg/edit/trunk/packages/components/src/draggable/README.md)

[  Previous: Divider](https://developer.wordpress.org/block-editor/reference-guides/components/divider/)

[  Next: DropZone](https://developer.wordpress.org/block-editor/reference-guides/components/drop-zone/)