Modifiers
Modify or restrict the behavior of draggable elements.
Overview
Modifiers are a type of plugin that modify or restrict the behavior of draggable elements. They can be used to create custom behaviors, such as restricting the movement of draggable elements to a specific axis or container.
Usage
Modifiers can be applied globally or to individual draggable elements.
Global modifiers
Modifiers can be applied globally by passing them to the DragDropManager instance.
For example, if you wanted to only enable the RestrictToHorizontalAxis
modifier:
Local modifiers
Modifiers can also be applied to individual draggable elements by passing them to the modifiers
option.
For example, if you wanted to only enable the RestrictToContainer
modifier for this specific draggable element, while using the RestrictToHorizontalAxis
globally for all other draggable elements:
Built-in modifiers
Abstract modifiers
Abstract modifiers are not tied to a specific environments. These modifiers can be imported from @dnd-kit/abstract/modifiers
.
Restricts the movement of draggable elements to the horizontal axis.
Restricts the movement of draggable elements to the vertical axis.
Concrete modifiers
Concrete modifiers are tied to specific environments, such as the DOM.
DOM
These modifiers can be imported from @dnd-kit/dom/modifiers
.
Restricts the movement of draggable elements to the window.
Restricts the movement of draggable elements to the container element.