Dragula is a lightweight JavaScript library that makes drag-and-drop between containers in the browser extremely simple. You provide one or more container elements and it handles all the DOM event wiring so users can drag items within and between containers with natural behavior. By default, any element in those containers can be picked up and dropped in any other container in the group, with sensible rules for what happens if the item is dropped elsewhere. The library includes configuration hooks for customizing what counts as a valid container, whether items are movable, where they can be dropped, and how they behave when “spilled” outside of containers. It works across modern browsers and even older ones, focusing on minimal dependencies and a straightforward API. The included CSS gives you a basic visual style for dragged items and placeholder states, while still being easy to override with your own styles.
Features
- Simple dragula(containers, options) API to enable drag-and-drop between DOM containers
- Sensible defaults that allow moving elements between containers with graceful cancel behavior on invalid drops
- Configurable hooks (isContainer, moves, accepts, invalid) for fine-grained control over what can be dragged where
- Options for direction, copying vs moving, revert behavior and removal on spill
- Lightweight implementation with minimal dependencies and built-in CSS that can be customized
- Widely used in sortable lists, kanban boards and dashboard layouts across many frameworks