Micro-interactions

Swipe Actions

List rows you swipe to show actions, like in iOS Mail. Drag a row and its buttons slide in from the side. Swipe all the way and the outer action fills the row and runs. An action like Archive then folds the row away. A quick flick works too. With full swipe off, the row pushes back when you pull past the last button. With a keyboard, the arrow keys show the actions and Enter runs one.

Install

bun add motion clsx tailwind-merge

Then copy 2 files into your project:

  • components/registry/swipe-actions/swipe-actions.tsx
  • lib/utils.ts

Props

PropTypeDefaultDescription
revealWidthnumber76Width of each action button once it is fully shown.
fullSwipebooleantrueSwipe far enough and the outer action fires on its own.
fullSwipeThresholdnumber60How far across the row a full swipe has to go.
rubberBandnumber0.55How much the row resists past the last button when full swipe is off. 0 is a hard stop. iOS uses 0.55.
velocityThresholdnumber500A flick faster than this opens or closes the row, however short it is.
stiffnessnumber500How hard the row springs to where it lands.
dampingnumber42How fast that spring settles. Lower values bounce.

What It Demonstrates

Swipe to dismiss
Dragging an element off-screen to close it, like a drawer or toast.
Drag
Moving an element by grabbing it, often with momentum when released.
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.
Spring
Motion driven by physics (tension, mass, damping) rather than a set duration.
Accordion / Collapse
A section smoothly expands and collapses its height to show or hide content.

Related Components

Appears In