Skip to main content
Plugins extend the core drag and drop functionality by adding features like visual feedback, auto-scrolling, accessibility announcements, and custom behaviors.

Overview

Plugins:
  • Extend drag and drop behavior without modifying core code
  • React to drag operation changes through effects
  • Can be configured globally or per-draggable
  • Support options for customization
  • Can be enabled/disabled dynamically
  • Follow a consistent lifecycle

Plugin base class

All plugins extend the Plugin base class:

Built-in plugins

The @dnd-kit/dom package includes several useful plugins:

Feedback

Provides visual feedback during drag operations:
The feedback plugin:
  • Creates a visual representation of the dragged element
  • Follows the pointer during drag
  • Supports custom rendering
  • Handles animations and transitions
Configuration:

Accessibility

Provides screen reader announcements:
Announces:
  • When a drag starts
  • When hovering over a droppable
  • When a drag ends (dropped or canceled)

AutoScroller

Automatically scrolls containers when dragging near edges:
Configuration:

Cursor

Manages cursor styles during drag:
Sets appropriate cursors:
  • grabbing while dragging
  • grab on hover
  • not-allowed when can’t drop

PreventSelection

Prevents text selection during drag:
This plugin is included by default and prevents unwanted text selection.

Core plugins

Some plugins are required for core functionality:

CollisionNotifier

Updates the drag target based on collision detection:
This plugin is automatically included in every manager.

ScrollListener & Scroller

These DOM-specific plugins track and manage scroll offsets:

Creating custom plugins

Extend the Plugin class to create custom functionality:

Basic example

With options

Analytics plugin

Visual feedback plugin

Plugin lifecycle

Construction

Plugins are instantiated when registered with the manager:

Effects

Use registerEffect to react to drag operation changes:

Destruction

Plugins are destroyed when the manager is destroyed:

Configuration

Global plugins

Apply to all drag operations:

Per-draggable plugins

Apply to specific draggables:
Per-draggable plugins are registered with the manager when the draggable is registered.

Plugin descriptors

The configure method returns a descriptor:
Managers and entities accept both constructors and descriptors:

Enable/disable plugins

Plugins can be enabled or disabled at runtime:
Disabled plugins:
  • Still exist in the registry
  • Effects still run
  • Should check isDisabled() and skip their logic

Accessing plugins

Get registered plugins from the manager:

Plugin registry

The manager maintains a plugin registry:
Set plugins:

Per-draggable plugin configuration

Draggables can look up their plugin configuration:
Usage:

Type safety

Plugins can be typed with their manager type:
Infer types from manager:

Best practices

Use effects for reactions: Always use registerEffect to react to drag operation changes. This ensures your plugin stays in sync with the reactive system.
Clean up resources: Implement destroy() if your plugin allocates resources (timers, event listeners, DOM elements).
Support options: Make your plugins configurable with options. Use the configure pattern for user-friendly configuration.
Respect disabled state: Check isDisabled() in your effects and skip logic when disabled.

Example: Undo/Redo plugin

Custom plugins

Build your own plugins

Modifiers

Transform coordinates

Plugins API

Plugin API reference

DOM plugins

Built-in DOM plugins