Skip to main content

Overview

Once you’ve mastered the basics, you’ll often need to handle multiple drop containers. This guide shows you how to create a drag and drop interface where items can be moved between multiple containers, like a kanban board or card organizer.

What You’ll Build

A multi-container drag and drop interface featuring:
  • Multiple drop zones with unique identities
  • Ability to drag items between any container
  • Visual feedback showing which container will receive the item
  • State management for tracking items across containers

Prerequisites

This guide assumes you understand the basics from the Simple Drag and Drop guide.

Implementation

Complete Example

Here’s a full working implementation with multiple containers:

Styling

Advanced: Using the Move Helper

For sortable lists within containers, dnd-kit provides a move helper from @dnd-kit/helpers:
This automatically handles moving items between containers and reordering within containers.

Key Takeaways

  • Structure your state as an object mapping container IDs to item arrays
  • Store container information in the draggable’s data property
  • Use event.operation.source and event.operation.target to identify containers
  • Remove items from the source container and add to the target container
  • The move helper from @dnd-kit/helpers can simplify state updates
  • Visual feedback helps users understand where items can be dropped

Common Patterns

Preventing Drops in Certain Containers

Limiting Items Per Container

Next Steps

  • Explore Nested Contexts for hierarchical structures
  • Learn about sortable lists for ordering within containers
  • Add animations with drag overlays for smoother interactions