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-mergeThen copy 2 files into your project:
- components/registry/reorder/reorder.tsx
- lib/utils.ts
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| axis | "y" | "x" | "y" | Which way the list runs, and which arrow keys move a row. |
| stiffness | number | 520 | Spring 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. |
| damping | number | 38 | Spring friction on the same. |
| handle | boolean | true | Restrict 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. |
| lift | number | 1.03 | Scale 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. |
| liftShadow | number | 0.35 | Shadow cast under a lifted row. |
| gap | number | 8 | Space between rows. |
| radius | number | 8 | Row corner radius. |
| density | "comfortable" | "compact" | "comfortable" | Row padding. |
| showIndex | boolean | true | Print 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. |
| accentColor | string (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
Live Activity
A live activity tracker in one black shape. A timer, a download, a delivery, a song and an AI agent take turns in it, and tapping it opens a full card. The text fades out before the shape moves and comes back after it stops, so it never stretches during the resize. The small pill and the big card share one clock and one state, so if you pause in the card, the pill is paused too. The agent is the main show. Three sparkles circle on a tilted orbit, the front one big and the back ones small, and they spin faster on every new step. The pill widens to show each new step's name, then shrinks back to the step count, and the card types out the command the agent is running.
Hover List
A display-type list where a shared accent block springs between rows on hover while the text indents and inverts.
Magnetic Button
A button that leans into your cursor. Caught in a magnetic field it slides toward the pointer while an amethyst aura swells with proximity, then snaps home on a spring and answers every click with a dark ripple bursting outward from the point of contact.
Segmented
A segmented control whose indicator travels on a shared layout id and smears in the direction it is moving.
Dial
A machined rotary knob: angular drag with detents you can feel on the way past, inertia on a flick, and a spring that settles into the nearest stop. The angle lives in a motion value rather than in React state, because a drag writes it sixty times a second and a spring more often than that, so the only thing React holds is the detent index, and only when that integer actually changes. Arrow keys step through the same spring the hand does, so the keyboard is not a second, worse path to the same control.
Lever
An industrial breaker lever with a real over-centre mechanism. Displayed travel lags the raw pointer travel by a bump curve peaked at the threshold, so approaching it the handle drags heavier, and crossing it the lag collapses and the handle races ahead of the finger. That is why a half-hearted push falls back the way a real breaker does. Release projects the flick's velocity past the threshold before choosing a side, so momentum can finish a throw the finger only started, and the keyboard commits through exactly the same spring the hand uses. The throw is a motion value. React holds only the committed side.