Skip to main content

Overview

Multiple sortable lists enable drag-and-drop between different containers, perfect for kanban boards, file organizers, and categorized item management. Items can be reordered within lists or moved between them.

Basic Multiple Lists

Key Concepts

Groups

The group prop associates items with their container:
When dragging between lists, dnd-kit uses groups to track where items came from and where they’re going.

Accept Types

The accept prop defines what types of draggables a sortable can receive:
This creates a type system for your drag-and-drop interactions:
  • Items can only be dropped into containers that accept their type
  • Columns that accept ['column', 'item'] can receive both

Collision Priority

When items overlap, collisionPriority determines which should be considered:
This ensures that when dragging over nested sortables (like items within columns), the correct target is selected.

Event Handling

onDragOver vs onDragEnd

Use onDragOver for:
  • Real-time visual feedback
  • Immediate state updates (optimistic UI)
Use onDragEnd for:
  • Persisting changes to backend
  • Non-optimistic updates (wait until drag completes)

Cancellation Handling

Always handle canceled drags to restore state:

Advanced Patterns

Styled Columns with Colors

Adding Items to Lists

Removing Items

Nested Sortables

Columns themselves can be sortable:
This allows users to reorder both columns and items within columns.

Sensors Configuration

Customize how drag operations are triggered:
This configuration:
  • Enables both mouse/touch and keyboard navigation
  • Allows activation via the element or its handle

Feedback Configuration

Control visual feedback during dragging:
Options:
  • 'clone': Shows a clone of the item while dragging
  • 'move': Moves the original item

Real-World Example: Kanban Board

Performance Optimization

  1. Memoize components: Use React.memo to prevent unnecessary re-renders
  2. Snapshot state: Keep a snapshot for quick rollback on cancel
  3. Debounce backend saves: Don’t save on every onDragOver

Next Steps