How atlassian/react-beautiful-dnd works
react-beautiful-dnd is a React library for accessible drag-and-drop list interactions. Applications compose DragDropContext, Droppable, and Draggable; users initiate movement through mouse, touch, keyboard, or custom sensors; the library tracks dimensions and drag state, calculates reorder or combine impact, and reports the completed drop to application responders. It also supports auto-scrolling, virtual lists, animation, and screen-reader announcements. Sampled source shows context setup, draggable registration, and component wiring; several domain relationships below rely on README statements because their implementation was not sampled.
Main entry points: app.jsx Context runtime · drag-drop-context.jsx Drag context · droppable Droppable area · responders Drop responders
Components 18
React API
- Drag context
src/view/drag-drop-context/drag-drop-context.jsx - Context runtime
src/view/drag-drop-context/app.jsx - Droppable area
src/view/droppable - Draggable item
src/view/draggable/draggable.jsx - Dimension publisher
src/view/use-draggable-publisher/use-draggable-publisher.js
Input and accessibility
- Input sensors
src/view/use-sensor-marshal/use-sensor-marshal.js - Focus management
src/view/use-focus-marshal - Screen reader
src/view/use-announcer
Drag state engine
- Drag store
src/state/create-store.js - Drag actions
src/state/action-creators.js - Dimension marshal
src/state/dimension-marshal/dimension-marshal.js - Item registry
src/state/registry - Drop impact
src/state/get-drag-impact - State transitions
src/state/reducer.js
Movement and feedback
- Auto-scrolling
src/state/auto-scroller - Drag animation
src/animation.js - Drop responders
src/state/middleware/responders
Other components
- Application
Connections 22
- Application → Drag context: composes
- Drag context → Context runtime: renders
src/view/drag-drop-context/drag-drop-context.jsx - Context runtime → Drag store: creates
src/view/drag-drop-context/app.jsx - Context runtime → Dimension marshal: creates
src/view/drag-drop-context/app.jsx - Context runtime → Auto-scrolling: creates
src/view/drag-drop-context/app.jsx - Context runtime → Item registry: uses
src/view/drag-drop-context/app.jsx - Drag context → Droppable area: contains
- Droppable area → Draggable item: contains
- Draggable item → Dimension publisher: registers dimensions
src/view/draggable/draggable.jsx - Dimension publisher → Item registry: registers item
src/view/use-draggable-publisher/use-draggable-publisher.js - Application → Input sensors: starts and controls
- Input sensors → Context runtime: dispatches drag
src/view/drag-drop-context/app.jsx - Context runtime → Drag actions: binds movement
src/view/drag-drop-context/app.jsx - Drag actions → State transitions: updates state
- Dimension marshal → Drop impact: supplies geometry
- Context runtime → Focus management: manages focus
src/view/drag-drop-context/app.jsx - Context runtime → Screen reader: announces status
src/view/drag-drop-context/app.jsx - Context runtime → Drop responders: publishes callbacks
- Context runtime → Drag animation: supports movement
- Auto-scrolling → Droppable area: scrolls containers
- Application → Drop responders: receives drop result
- Drop impact → Drop responders: determines drop result