Skip to content

Physics-based spring animations

damped is an animation library built on real spring physics. Retarget or reverse any animation at any moment and the new spring starts from the element's current position and velocity.

Live spring · running on damped

Position against velocity. Every interruption keeps its place on this curve.

It plays on load: the mass swings out, across, and home again, retargeted mid-flight every time. Drag the mass and let go, or press the track while it moves. Arrow keys, Home and End also move the rest point.

Packages

The same analytic spring runs in the browser, in React and in React Native. Pick the layer you work at.

@damped/core

Web

Animate elements, reorder with FLIP, morph one element into another and run springs on the compositor.

Reference for @damped/core
bun add @damped/core
npm install @damped/core
import { animate } from "@damped/core";
const card = document.getElementById("card")!;
animate(card, { x: 240 }, { bounce: 0.15 });

@damped/react

React 19

Hooks and a Presence component. Values reach the DOM without re-rendering on every frame.

Reference for @damped/react
bun add @damped/react @damped/core
npm install @damped/react @damped/core
import { useSpring } from "@damped/react";
export function Card({ open }: { open: boolean }) {
const ref = useSpring<HTMLDivElement>({ scale: open ? 1.05 : 1 });
return <div ref={ref}>Card</div>;
}

@damped/native

React Native

withDamped, a withSpring replacement for Reanimated that keeps velocity on reversal.

Reference for @damped/native
bun add @damped/native
npm install @damped/native
import { withDamped } from "@damped/native";
import { useSharedValue } from "react-native-reanimated";
export function useToggle() {
const x = useSharedValue(0);
return () => {
x.value = withDamped(x.value ? 0 : 200, { bounce: 0.15 });
};
}

Why damped

What the library guarantees every time it moves an element.

  1. 01

    Interruptions keep their momentum

    Retarget a running animation, or reverse it halfway, and the new spring starts from where the element is, moving at the speed it had. Nothing snaps back to a standstill.

    Interruption and reversal
  2. 02

    Exact state at any time

    A spring is a closed-form function of time, not a per-frame integration. The same position and velocity come out at 60 Hz, at 144 Hz and on an irregular frame cadence, to within 1e-12.

    Springs, explained
  3. 03

    Smooth while the main thread is busy

    The optional compositor driver hands the browser a sampled keyframe animation. In Chromium, a 250 ms busy loop left the compositor box moving while the same spring on the main thread stood still.

    The compositor driver
  4. 04

    Reduced motion is respected

    Animations follow prefers-reduced-motion by default: movement jumps to its destination while fades and crossfades stay, so the interface still reads as changing.

    Reduced motion and accessibility

Spec sheet

Minified and gzipped, each entry point bundled the way an application would bundle it.

MeasureValueNote
animate3.95 KBgzipped, for an app that only calls animate
@damped/core6.99 KBgzipped, for the whole package
compositor driver~0.74 KBgzipped, added only when you import it
React renders0per animation frame; values reach the DOM through refs

Guides