Micro-interactions

Dismiss

Throw the top card away and the stack closes up behind it. Distance commits, but so does speed — a fast flick from barely anywhere counts, and anything short of both rubber-bands home carrying the velocity you let go at.

Install

bun add motion clsx tailwind-merge

Then copy 2 files into your project:

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

Props

PropTypeDefaultDescription
axis"x" | "y" | "both""x"Which way a card can leave. Sideways is the toast convention; downward reads as filing something away rather than discarding it.
thresholdnumber32How far across its own width a card must travel to commit. Distance is only half the test — a flick past the speed threshold commits from anywhere.
velocityThresholdnumber520Release speed that commits regardless of how far the card actually moved. Without this a quick flick just springs back and the gesture feels deaf.
rubberBandnumber0.35Give past the drag bounds. 0 is a hard wall; 1 follows the finger exactly and loses the sense that the card is resisting you.
stackDepthnumber3How many cards are visible at once. Past four the ones at the back stop being legible and start being texture.
stackOffsetnumber14Vertical step between one card and the next down the stack.
stackScalenumber0.05Scale lost per card down the stack. This is what sells depth — offset alone reads as a list.
rotateOnDragnumber8Degrees the card leans at the far edge of the throw. Derived from displacement, not animated separately, so an interrupted throw can never desync it.
stiffnessnumber420How hard the stack springs into its new slot after a card leaves.
dampingnumber32How fast that spring settles. Low values let the stack overshoot and bounce, which reads as lightweight.

What It Demonstrates

Swipe to dismiss
Dragging an element off-screen to close it, like a drawer or toast.
Rubber-banding
Resistance and snap-back when you drag past a boundary (the iOS overscroll feel).
Velocity
How fast and in which direction an element is moving. A spring carries it into the next animation when interrupted, so a flicked element keeps its speed.
Momentum
Motion that carries velocity, especially after a drag or interruption.
Interruptible animation
An animation that can be smoothly redirected mid-flight instead of finishing first.
Drag
Moving an element by grabbing it, often with momentum when released.
Spring
Motion driven by physics (tension, mass, damping) rather than a set duration.

Related Components

Appears In