Reorder components enable drag-to-reorder functionality with automatic layout animations. Use Reorder.Group to create a reorderable container and Reorder.Item for each draggable element.
Usage
Components
Reorder.Group
Container component that manages reordering state and coordinates layout animations.Reorder.Item
Draggable item component that can be reordered within aReorder.Group.
Reorder.Group Props
Array of values in the current order. Must be kept in sync with your state.
Callback fired when items are reordered. Receives the new order array.Typically, this is your state setter function.
The axis to reorder along. Items will be draggable on this axis by default.Set individual items to
drag to allow dragging on both axes.HTML element to render as. Defaults to
"ul".HTMLMotionProps are also supported (e.g., style, className, event handlers).
Reorder.Item Props
The value this item represents in the
values array. Used to track and reorder items.HTML element to render as. Defaults to
"li".Enable layout animations. Set to
"position" to only animate position changes, not size.HTMLMotionProps are also supported, including drag gesture props.
Examples
Basic Vertical List
Horizontal List
Complex Items
With Custom Drag Handle
With Animation on Drag
Grid Layout (2D Reordering)
With Remove Animation
TypeScript
How It Works
Reorder.Grouptracks the current positions of all items- When an item is dragged, it calculates its new position
- The
onReordercallback fires with the new array order - Layout animations smoothly transition items to their new positions
- The component uses
layoutIdinternally for smooth reordering
Notes
- Each
Reorder.Itemmust have a uniquekeyprop - The
valueprop must reference the actual item in thevaluesarray - Items are draggable only along the specified
axisby default - Set
dragprop onReorder.Itemto enable dragging in both directions - Auto-scrolling is enabled when dragging near container edges
- Works with
AnimatePresencefor enter/exit animations
Related
- motion - Core animation component with drag support
- LayoutGroup - Coordinate layout animations
- drag guide - Learn more about drag gestures
- layout animations guide - Understanding layout animations