Now Available: Notion-like editor templateNotion-style editor for Tiptap Cloud

Move Node Button

Available in Start plan

A fully accessible move node button for Tiptap editors. Reorder selected nodes or blocks in the editor with keyboard shortcut support and smart selection handling.

Installation

Add the component via the Tiptap CLI:

npx @tiptap/cli@latest add move-node-button

Components

<MoveNodeButton />

A prebuilt React component that moves nodes up or down in the editor.

Usage

export default function MyEditor() {
  return (
    <>
      <MoveNodeButton
        editor={editor}
        direction="up"
        text="Move Up"
        hideWhenUnavailable={true}
        showShortcut={true}
        onMoved={(direction) => console.log(`Node moved ${direction}!`)}
      />
      <MoveNodeButton
        editor={editor}
        direction="down"
        text="Move Down"
        hideWhenUnavailable={true}
        showShortcut={true}
        onMoved={(direction) => console.log(`Node moved ${direction}!`)}
      />
    </>
  )
}

Props

NameTypeDefaultDescription
editorEditor | nullundefinedThe Tiptap editor instance
direction"up" | "down"RequiredDirection to move the node
textstringundefinedOptional text label for the button
hideWhenUnavailablebooleanfalseHides the button when moving is not available
onMoved(direction: "up" | "down") => voidundefinedCallback fired after a successful move
showShortcutbooleanfalseShows a keyboard shortcut badge (if available)

Hooks

useMoveNode()

A custom hook to build your own move node button with full control over rendering and behavior.

Usage

function MyMoveNodeButton({ direction }: { direction: 'up' | 'down' }) {
  const { isVisible, handleMoveNode, canMoveNode, label, shortcutKeys, Icon } = useMoveNode({
    editor: myEditor,
    direction,
    hideWhenUnavailable: true,
    onMoved: (direction) => console.log(`Node moved ${direction}!`),
  })

  if (!isVisible) return null

  return (
    <button onClick={handleMoveNode} disabled={!canMoveNode} aria-label={label}>
      <Icon />
      {label}
      {shortcutKeys && <Badge>{parseShortcutKeys({ shortcutKeys })}</Badge>}
    </button>
  )
}

Props

NameTypeDefaultDescription
editorEditor | nullundefinedThe Tiptap editor instance
direction"up" | "down"RequiredDirection to move the node
hideWhenUnavailablebooleanfalseHides the button if moving cannot be performed
onMoved(direction: "up" | "down") => voidundefinedCallback fired after successful move

Return Values

NameTypeDescription
isVisiblebooleanWhether the button should be rendered
canMoveNodebooleanIf a node can be moved in the specified direction
handleMoveNode() => booleanFunction to move the selected node
labelstringAccessible label text for the button
shortcutKeysstringKeyboard shortcut for the direction
IconReact.FCIcon component for the move button (AlignTopIcon/AlignBottomIcon)

Utilities

canMoveNode(editor, direction)

Checks if a node can be moved in the specified direction in the current editor state.

import { canMoveNode } from '@/components/tiptap-ui/move-node-button'

const canMoveUp = canMoveNode(editor, 'up')
const canMoveDown = canMoveNode(editor, 'down')

moveNode(editor, direction)

Programmatically moves the selected node or block in the specified direction.

import { moveNode } from '@/components/tiptap-ui/move-node-button'

const success = moveNode(editor, 'up')
if (success) {
  console.log('Node moved successfully!')
}

shouldShowButton(props)

Utility to determine if the move button should be visible based on editor state and configuration.

import { shouldShowButton } from '@/components/tiptap-ui/move-node-button'

const shouldShow = shouldShowButton({
  editor,
  direction: 'up',
  hideWhenUnavailable: true,
})

Keyboard Shortcuts

The move node button supports the following keyboard shortcuts:

  • Cmd/Ctrl + Shift + Arrow Up: Move the selected node up
  • Cmd/Ctrl + Shift + Arrow Down: Move the selected node down

The shortcuts are automatically registered when using either the <MoveNodeButton /> component or the useMoveNode() hook. These shortcuts work with any block-level node including paragraphs, headings, blockquotes, and code blocks.

Requirements

Dependencies

  • @tiptap/react - Core Tiptap React integration
  • @tiptap/pm/state - ProseMirror state management
  • react-hotkeys-hook - Keyboard shortcut management

Referenced Components

  • use-tiptap-editor (hook)
  • use-mobile (hook)
  • button (primitive)
  • badge (primitive)
  • tiptap-utils (lib)
  • tiptap-advanced-utils (lib)
  • align-top-icon (icon)
  • align-bottom-icon (icon)