Micro-interactions

Reorder

A sortable list that answers to a finger and to a keyboard equally — grab a row, and the rest step aside to make the space.

Install

bun add motion clsx tailwind-merge

Then copy 2 files into your project:

  • components/registry/reorder/reorder.tsx
  • lib/utils.ts

Props

PropTypeDefaultDescription
axis"y" | "x""y"Which way the list runs, and which arrow keys move a row.
stiffnessnumber520Spring tension as the displaced rows close up. This is the only motion in the component that is not under your finger, so it is the one that decides whether the list feels attached to the drag.
dampingnumber38Spring friction on the same.
handlebooleantrueRestrict the drag to the grip. Off makes the whole row the surface, which is quicker to hit and costs you text selection and a scroll gesture that starts on a row.
liftnumber1.03Scale of a row while it is off the ground. Past about 1.06 the row stops reading as lifted and starts reading as a different row.
liftShadownumber0.35Shadow cast under a lifted row.
gapnumber8Space between rows.
radiusnumber8Row corner radius.
density"comfortable" | "compact""comfortable"Row padding.
showIndexbooleantruePrint the position of each row. Worth leaving on wherever the order is the data rather than a preference — it is the only on-screen confirmation that a keyboard move landed where the announcement said it did.
accentColorstring (hex)"#a855f7"Grip tint, and the outline on a row the keyboard is carrying. A pointer drag shows itself by moving; a keyboard grab has to be drawn.

What It Demonstrates

Drag to reorder
Dragging items in a list to rearrange them, while the others shift to make room.
Drag
Moving an element by grabbing it, often with momentum when released.
Layout animation
When an element's size or position changes, it animates to the new spot instead of snapping.
Spring
Motion driven by physics (tension, mass, damping) rather than a set duration.
Press / Tap feedback
A subtle scale-down when an element is clicked, so it feels physical.

Related Components

Appears In