---
title: "Drag Handle extension"
description: "Enable dragging nodes around your Tiptap Editor with the Drag Handle Extension. Learn how to set it up here in the Docs!"
---

> This page is for Tiptap 2.x. [See the latest version of this page.](https://tiptap.dev/docs/editor/extensions/functionality/drag-handle.md)

# Drag Handle extension

Enable dragging nodes around your Tiptap Editor with the Drag Handle Extension. Learn how to set it up here in the Docs!

Have you ever wanted to drag nodes around your editor? Well, we did too—so here’s an extension for that.

The `DragHandle` extension allows you to easily handle dragging nodes around in the editor. You can define custom render functions, placement, and more.

> **Interactive demo:** [DragHandle](https://v2--tiptap-embed.netlify.app/preview/Extensions/DragHandle)

## Install

```bash
npm install @tiptap/extension-drag-handle
```

## Settings

### render

Renders an element that is positioned with tippy.js. This is the element that will be displayed as the handle when dragging a node around.

```js
DragHandle.configure({
  render: () => {
    const element = document.createElement('div')

    // Use as a hook for CSS to insert an icon
    element.classList.add('custom-drag-handle')

    return element
  },
})
```

### tippyOptions

Options for tippy.js. You can pass any options that are available in the [tippy.js documentation](https://atomiks.github.io/tippyjs/v6/all-props/).

Default: `undefined`

```js
DragHandle.configure({
  tippyOptions: {
    placement: 'left',
  },
})
```

### onNodeChange

Returns a node or null when a node is hovered over. This can be used to highlight the node that is currently hovered over.

Default: `undefined`

```js
DragHandle.configure({
  onNodeChange: ({ node, editor, pos }) => {
    if (!node) {
      selectedNode = null
      return
    }
    // Do something with the node
    selectedNode = node
  },
})
```

## Commands

### lockDragHandle()

Locks the draghandle in place and visibility. If the drag handle was visible, it will remain visible until unlocked. If it was hidden, it will remain hidden until unlocked.

This can be useful if you want to have a menu inside of the drag handle and want it to remain visible whether the drag handle is moused over or not.

```js
editor.commands.lockDragHandle()
```

### unlockDragHandle()

Unlocks the draghandle. Resets to default visibility and behavior.

```js
editor.commands.unlockDragHandle()
```

### toggleDragHandle()

Toggle draghandle lock state. If the drag handle is locked, it will be unlocked and vice versa.

```js
editor.commands.toggleDragHandle()
```
