Skip to main content

React animation example

React Spring Animation: Interactive Spring Physics Demo

Spring animations feel natural because they have no fixed duration: they settle when the physics says so. This demo lets you feel the two numbers that matter. Drag the ball away from its anchor and release it; the graph below records its position so you can see under-damped wobble turn into a clean settle as damping rises.

  • 4.4 KB file
  • 5 live inputs
  • React runtime
Live, try it

How this spring playground works

  • Acceleration is stiffness × displacement minus damping × velocity, integrated every frame.
  • Damping ratio is shown live: below 1 the spring overshoots, at 1 it settles fastest without overshoot.
  • Stiffness and damping are inputs, so you can tune a feel here and reuse the numbers in your own code.

Add it to your React app

Install exodeui, download the file below, and paste this. The code updates as you customize. Other runtimes are in the other tabs.

import { ExodeUICanvas } from 'exodeui';

// react-spring-animation.bexode goes in /public (download it below)
export function ReactSpringAnimation() {
  return (
    <ExodeUICanvas
      src="/react-spring-animation.bexode"
      fit="Layout"
      autoPlay
      interactive
      onTrigger={(name) => {
        // fires: 'release'
      }}
      style={{ width: '100%', height: 520 }}
    />
  );
}

Inputs

InputTypeDefaultRange
stiffnessNumber18020 – 600
dampingNumber101 – 60
accentText#f59e0bhex colour
accent2Text#38bdf8hex colour
bgText#0a0a0chex colour

Events: release

More React animations

The same idea in other frameworks: SwiftUI spring response comparison