Skip to main content
Sortable lists combine drag and drop functionality with automatic reordering. The useSortable hook provides everything you need to build sortable interfaces.

Basic Sortable List

Create a simple sortable list by combining DragDropProvider with useSortable:
The move helper automatically calculates the new array order based on the drag operation.

Sortable Grid

Build a sortable grid by adjusting the container layout:

Using the Sortable Hook

The useSortable hook returns several useful properties and refs:

Drag Handles

Add a drag handle to make only part of the item draggable:
Use drag handles when items contain interactive elements like buttons or inputs. This prevents conflicts between dragging and clicking.

Multi-Container Sorting

Create sortable items that can move between different lists using groups:

Disabling Sortable Items

Disable specific items from being dragged or accepting drops:

Custom Data

Attach custom data to sortable items:
Access this data in event handlers:
Always provide a unique id for each sortable item. Using array indices as IDs can cause issues when items are added or removed.

Advanced: Separate Source and Target

For complex layouts, you can specify different elements for the draggable source and drop target:
This pattern is useful when you need visual spacing around drop zones.

Next Steps

1

Customize Transitions

Learn how to configure animations and transitions for smooth sorting effects
2

Add Accessibility

Ensure your sortable lists are accessible with keyboard navigation
3

Optimize Performance

Improve rendering performance for large lists with optimization techniques