Pragmatic drag and drop
repository·main·Indexed 11 days ago
https://github.com/atlassian/pragmatic-drag-and-dropA low-level, framework-agnostic, and headless toolchain for implementing robust drag and drop experiences using native browser capabilities. Version 1.0.0 provides a tiny core (~4.7kB) compatible with any tech stack (React, Vue, Svelte, Angular) and includes optional extensions for auto-scrolling, visual flourishes, hitboxes, live regions for screen readers, and migration utilities from react-beautiful-dnd.
What's inside Pragmatic drag and drop
- Pragmatic drag and drop is a high-performance drag and drop library designed to work with any tech stack and any user experience. It provides the core primitives required to build fast, flexible drag and drop interactions without being tied to a specific framework like React or Vue.
Overview of Pragmatic drag and drop
mainPragmatic drag and drop is a low-level, framework-agnostic toolchain designed to enable safe and successful usage of the browser's built-in drag and drop functionality. It is a 'headless' library, meaning it provides the logic and behavior without enforcing any specific visual language or styling, giving developers full control over the UI.
Key Characteristics
- Tiny Core: The core package is approximately
4.7kB. - Incremental & Headless: You only import the pieces you need, and the library does not dictate how your components look.
- Framework Agnostic: It works with any view layer, including React, Svelte, Vue, and Angular.
- Deferred Compatible: You can delay loading core and optional packages to improve page load speeds.
- Broad Support: Full feature support across Firefox, Safari, Chrome, iOS, and Android.
- Virtualization Support: Designed to work with virtualized lists and complex experiences.
- Tiny Core: The core package is approximately
What is the @atlaskit/pragmatic-drag-and-drop-flourish package?
mainThe@atlaskit/pragmatic-drag-and-drop-flourishpackage is an optional extension for Pragmatic Drag and Drop. It is designed to add visual polish and feedback (flourish) to drag and drop interactions, such as triggering animations or visual cues after a move is completed.Overview of @atlaskit/pragmatic-drag-and-drop-react-accessibility
main@atlaskit/pragmatic-drag-and-drop-react-accessibilityis an optional package for Pragmatic drag and drop that provides React components designed to assist in setting up accessible drag and drop experiences.Dependencies
To use this package, you must also have:
- The core
@atlaskit/pragmatic-drag-and-droppackage react@emotion/react(used for styling)- Various Atlassian Design System packages
Customization
You are welcome to reimplement the logic from this package using your own tech stack if you prefer not to use Emotion or Atlassian Design System components.
React 19 Compatibility
This package includes React 19 in its supported peer dependency range. However, as it is not currently tested directly against React 19, users should monitor for potential issues and report them via GitHub if encountered.
- The core
Overview of React drop indicators
mainThe
@atlaskit/pragmatic-drag-and-drop-react-drop-indicatorpackage provides React components for displaying visual drop indicators (e.g., lines or borders) that show users where an item will be dropped.These components are designed to work with the
@atlaskit/pragmatic-drag-and-drop-hitboxpackage to visualize hitbox information.Key Dependencies:
@atlaskit/pragmatic-drag-and-drop(core)@atlaskit/pragmatic-drag-and-drop-hitbox(optional package for hitbox data)react@atlaskit/tokens(for colors)compiled(for styling)
Explore Pragmatic drag and drop implementation examples
mainPragmatic drag and drop provides low-level building blocks to create any web-supported drag and drop experience. The library is composed of a core package and various optional packages.
Common UI patterns demonstrated in the examples include:
- Lists: Simple vertical or horizontal lists.
- Boards: Kanban-style boards (e.g., Trello-like) with support for shadow-based drop placement.
- Grids: Grid layouts supporting item swapping or insertion.
- Tables: Drag and drop within tabular data structures.
- Trees: Hierarchical structures (supports both modern
list-itemoutputs and legacytree-itemoutputs). - Files: Capturing files dragged from the OS using the external adapter.
- Side Navigation: Rich interactions within navigation systems.
- Virtualization: Integration with virtualization libraries like TanStack Virtual to handle large datasets.
- Drawing & Resizing: Complex interactions like freehand drawing or element resizing.
Use @atlaskit/pragmatic-drag-and-drop-flourish for visual effects
main@atlaskit/pragmatic-drag-and-drop-flourishis an optional package designed to add visual flourish and polish to drag and drop experiences built with Pragmatic drag and drop. It is intended to enhance the user interface during drag operations.Use @atlaskit/pragmatic-drag-and-drop-live-region for screen reader messaging
mainThe@atlaskit/pragmatic-drag-and-drop-live-regionpackage is an optional extension for Pragmatic drag and drop. It provides tools to enable screen reader messaging, which is essential for communicating drag-and-drop state changes and alternative interaction flows to users relying on assistive technologies.Use @atlaskit/pragmatic-drag-and-drop-react-drop-indicator for visual drop indicators
mainThe@atlaskit/pragmatic-drag-and-drop-react-drop-indicatorpackage provides React components designed to give users visual feedback about where an item will be placed during a drag-and-drop operation (for example, rendering a line to indicate an insertion point). This is an optional package used to enhance the user experience by making the drop target or insertion point explicit.Use @atlaskit/pragmatic-drag-and-drop-hitbox to attach interaction information to drop targets
mainThe@atlaskit/pragmatic-drag-and-drop-hitboxpackage is an optional extension for Pragmatic drag and drop. It allows you to attach specific interaction information to a drop target, which can be useful for fine-grained control over how drop targets respond to drag interactions.Use @atlaskit/pragmatic-drag-and-drop-unit-testing for screen reader messaging
mainThe@atlaskit/pragmatic-drag-and-drop-unit-testingpackage is an optional utility that enables screen reader messaging for alternative drag-and-drop flows during testing. This allows you to verify that your implementation correctly communicates state changes to users relying on assistive technologies.Use @atlaskit/pragmatic-drag-and-drop-auto-scroll for automatic scrolling
mainThe@atlaskit/pragmatic-drag-and-drop-auto-scrollpackage is an optional extension for Pragmatic drag and drop that enables automatic scrolling during a drag operation. It is designed to work with any configuration of scrollable entities, allowing you to dynamically change how your scrollable containers behave during a drag.