---
name: fluid-interactions
description: "Build gesture-driven web interfaces that feel native: drags, flicks, sheets, swipe-back, swipe actions, pull to refresh, scrubbers, pinch to zoom, card-to-detail morphs and app-switcher style gestures. Use when adding or fixing anything the user drags, flicks, swipes or pinches, when an animation needs to start from the finger's speed, when something should rubber band at an edge, or when a gesture feels stuck, jumpy or janky on touch."
title: fluid-interactions
canonical_url: https://skilld.dev/gh/rndrealm/fluid-interactions
last_updated: 2026-11-19T19:10:37.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [code/physics.ts](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/code/physics.ts), [code/use-drag.ts](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/code/use-drag.ts), [code/use-motion-preference.ts](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/code/use-motion-preference.ts), [code/use-pinch.ts](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/code/use-pinch.ts), [references/direction-lock.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/direction-lock.md), [references/drag-and-momentum.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/drag-and-momentum.md), [references/gesture-modes.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/gesture-modes.md), [references/morphing.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/morphing.md), [references/pinch.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/pinch.md), [references/pointer-events.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/pointer-events.md), [references/reduced-motion.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/reduced-motion.md), [references/scrubbing.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/scrubbing.md), [references/sheets.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/sheets.md), [references/springs.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/springs.md), [references/swipe-back.md](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/swipe-back.md).
>
> If the user asked to install this Skill, run `npx skilld install rndrealm/fluid-interactions/fluid-interactions`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/fluid-interactions`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/rndrealm/fluid-interactions/fluid-interactions) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/fluid-interactions`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/fluid-interactions --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/fluid-interactions --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Fluid interactions

Interfaces where motion behaves like physical objects instead of playing back a timeline. That covers:

- **Gestures:** things follow the finger, carry its speed when released, land where a flick was heading, resist at their edges, and can be caught mid-animation.
- **Transitions:** sheets, navigation, and views that grow out of the thing you tapped and can be dragged back.
- **Gesture modes:** one gesture doing different things depending on how it moves.
- **Getting it right everywhere:** touch quirks, performance, and reduced motion.

## Use motion

Always build these interactions with [motion](https://motion.dev). Its springs start from a velocity, its motion values update without re-rendering, and it follows reduced motion, which is everything this skill relies on. Don't use GSAP, anime.js or CSS transitions for them; the code here and in the references assumes motion. (The one hand-written loop, coasting in a custom scroller, still writes to a motion value and hands off to a motion spring.)

**Install it before writing any code** if it isn't in `package.json`, using the project's package manager (check the lockfile):

```sh
npm install motion     # package-lock.json
pnpm add motion        # pnpm-lock.yaml
yarn add motion        # yarn.lock
bun add motion         # bun.lock / bun.lockb
```

- **React:** import from `motion/react` (`motion`, `animate`, `useMotionValue`, `useTransform`, `MotionConfig`, `useReducedMotion`).
- **Already has `framer-motion`:** that's motion under its old name. Use it as it is, importing from `framer-motion`; don't install both.
- **Already uses another animation library:** keep it for whatever it already does, and add motion alongside it for these interactions. Don't rebuild these patterns in the other library.

Never fake a spring with a duration and an easing curve (`elastic`, `back`, cubic-bezier overshoot). They can't start from the finger's speed.

## The rules

1. **Animate with springs, not durations.** A spring only needs a target and a starting velocity, so it can pick up from wherever the finger left off. Describe springs by response (seconds) and damping ratio with `springFromResponse`, not raw stiffness and damping. See [springs](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/springs.md).
2. **Hand the release velocity to the spring.** Track the pointer with `VelocityTracker` (last 100ms only) and pass `velocity` into the animation. Without it, the element stops dead for a frame before setting off.
3. **Everything is interruptible.** On pointer down, `stop()` the animation and read the current value as the new origin. Never block input while something is animating. Decide state (open or closed, which page is current) from where an animation is **heading**, not from the value or `onComplete`: a spring looks done long before it finishes. See [drag and momentum](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/drag-and-momentum.md) and [decide from the target](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/springs.md#decide-from-the-target-not-the-value).
4. **Decide where it lands from where it was going.** On release, `project(velocity)` gives where a flick would coast to; snap to the nearest target from that point, not from the release point. That is what lets a short, fast flick skip a detent.
5. **Rubber band past the edges** instead of hard-stopping: `applyRubberBand(value, min, max, d)`. The further you pull, the less it moves.
6. **Directions that lead nowhere resist.** If only one direction does something (down dismisses, right goes back), the others still move, but under a rubber band, then spring back on release. Don't freeze them and don't let them move freely: free movement suggests an action that isn't there. This is only for something the user is holding that moves freely. If the other axis belongs to something else (page scroll, a parent list), hand it off with a direction lock instead of rubber banding. See [drag and momentum](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/drag-and-momentum.md#directions-with-no-action).
7. **Lock the direction before acting.** Wait about 10px, then commit to an axis. Only capture the pointer after the lock, so taps and the other axis (usually native scroll) still work. See [direction lock](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/direction-lock.md).
8. **Per-frame work never touches React state.** Use refs and motion values (or direct DOM writes). Only set state on release or on a discrete change.
9. **Move with transforms, not layout.** `x`, `y`, `scale`, `opacity`. Read layout (`getBoundingClientRect`, `clientWidth`) once at the start or end of a gesture, never every frame.
10. **Always end the gesture.** Handle `pointerup`, `pointercancel` and `lostpointercapture`. A gesture that misses its end leaves the UI stuck. See [pointer events](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/pointer-events.md).
11. **Respect reduced motion** by softening what moves by itself, never what the finger drives. See [reduced motion](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/reduced-motion.md).
12. **One gesture can mean several things.** How it moves (where it started, distance, speed, a pause, a second axis) can pick between related outcomes, like swiping up to go home or pausing to open the app switcher, or moving away from a scrubber to scrub more finely. The plain version must always work, and the mode must show before release. See [gesture modes](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/gesture-modes.md).

## Code

Copy these into the project and adapt them. `physics.ts` has no dependencies; the hooks need React, and `use-motion-preference.ts` needs motion.

- [code/physics.ts](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/code/physics.ts): `springFromResponse`, `noBounce`, `VelocityTracker`, `rubberBand`, `applyRubberBand`, `rubberBandInverse`, `unapplyRubberBand`, `project`, `DECELERATION`, `nearest`, `nearestPoint`, `clamp`, `FADE`.
- [code/use-drag.ts](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/code/use-drag.ts): a pointer-events drag hook that reports the offset from the start and the release velocity, and always calls `onEnd`.
- [code/use-pinch.ts](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/code/use-pinch.ts): a multi-finger hook that reports the fingers' midpoint and how far apart they've moved, re-measures whenever a finger is added or lifted, and detects double taps.
- [code/use-motion-preference.ts](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/code/use-motion-preference.ts): `{ reduceMotion, spring }`, where `spring()` drops the bounce when reduced motion is on.

## The basic shape of every gesture

```tsx
const x = useMotionValue(0);
const origin = useRef(0);

const drag = useDrag({
  onStart: () => {
    x.stop(); // catch it mid-flight
    origin.current = x.get(); // continue from where it is on screen
  },
  onMove: (delta) => {
    x.set(applyRubberBand(origin.current + delta.x, min, max, width));
  },
  onEnd: (velocity) => {
    const landing = x.get() + project(velocity.x);
    animate(x, nearest(landing, targets), {
      ...spring(SNAP),
      velocity: velocity.x,
    });
  },
});

return (
  <motion.div {...drag} style={{ x }} className="touch-none select-none" />
);
```

## Patterns

Read the reference for the pattern you are building:

| Building                                                                                                | Read                                                 |
| ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| Any spring, picking response and damping                                                                | [springs](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/springs.md)                     |
| Draggable or flickable element, snapping to corners or points, custom scroller with momentum and paging | [drag and momentum](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/drag-and-momentum.md) |
| Horizontal swipe inside a vertical list, swipe actions, pull to refresh                                 | [direction lock](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/direction-lock.md)       |
| Bottom sheet with detents                                                                               | [sheets](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/sheets.md)                       |
| Video or audio scrubber with fine scrubbing                                                             | [scrubbing](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/scrubbing.md)                 |
| Thumbnail that grows into a detail view and drags back down to close                                    | [morphing](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/morphing.md)                   |
| Edge swipe to go back in a navigation stack                                                             | [swipe back](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/swipe-back.md)               |
| Pinch to zoom and pan an image or canvas, double tap to zoom, trackpad pinch                            | [pinch](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/pinch.md)                         |
| One gesture with several outcomes or modes (home bar, fine scrubbing, stretching swipe actions)         | [gesture modes](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/gesture-modes.md)         |
| Reduced motion                                                                                          | [reduced motion](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/reduced-motion.md)       |
| A gesture that freezes, gets stuck, or breaks taps on touch                                             | [pointer events](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/pointer-events.md)       |

## Defaults that feel right

| Thing                                                 | Value                                               |
| ----------------------------------------------------- | --------------------------------------------------- |
| Most UI springs                                       | `springFromResponse(0.35–0.45, 0.85–0.9)`           |
| Navigation, paging, anything that shouldn't overshoot | damping ratio `1`                                   |
| Velocity window                                       | last 100ms                                          |
| Direction lock threshold                              | 10px                                                |
| Lock ratio for a strict axis                          | the winning axis is 2× the other                    |
| Rubber band constant                                  | `c = 0.55`, `d` = the container's size on that axis |
| Projection deceleration                               | `0.998` (normal), `0.99` (fast, stops sooner)       |
| Edge-swipe zone                                       | 24px from the edge                                  |
| Reduced-motion fade                                   | 200ms ease-out                                      |

Two choices have their own guidance, so don't guess them: how much a spring should bounce ([springs](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/springs.md#how-much-bounce)) and whether a scroller coasts normally, stops fast or pages ([drag and momentum](https://skilld.dev/api/skills-raw/rndrealm/fluid-interactions/fluid-interactions/references/drag-and-momentum.md#normal-fast-or-paging)). When unsure, no bounce and normal deceleration.

## Checklist before calling it done

- [ ] Grab it mid-animation: it stops exactly where it is, no jump.
- [ ] Act again the moment an animation looks finished (open another row, tap the revealed page, swipe the other way): it responds straight away, no dead quarter-second.
- [ ] Flick it: it leaves at the finger's speed, no hitch on release.
- [ ] Drag past the edge: it resists and springs back.
- [ ] Drop something that can rest anywhere inside its bounds: it stays exactly there, no wobble.
- [ ] Drag in a direction that does nothing: it resists (not frozen, not free) and springs back.
- [ ] On a phone: drag slowly; it tracks the finger and doesn't scroll the page (`touch-action`).
- [ ] Taps on buttons and rows inside the draggable still work.
- [ ] Put a second finger down mid-drag: nothing breaks.
- [ ] Switch apps or open the context menu mid-drag: it settles, it doesn't stay stuck.
- [ ] Turn on reduced motion: no overshoot, big automatic movements fade, dragging is unchanged.
