Course contentsShow
← React
Lesson 1993 of 2,39645. AnimationsFree lesson

Spring Configuration: Tension, Friction, Mass

Tune spring behavior with config presets (default, gentle, wobbly, stiff, slow, molasses) and custom parameters.

Spring Configuration: Tension, Friction, Mass

What you'll learn: How to fine-tune React Spring's physics-based animations by adjusting spring parameters or choosing preset configurations.

The Physics Behind Springs

React Spring simulates real physics. Just like a physical spring, you can control three core parameters:

  • Tension (default: 170): How stiff the spring is. Higher values = faster, snappier motion.
  • Friction (default: 26): How much resistance slows the spring. Lower values = more bouncing.
  • Mass (default: 1): How heavy the object is. Higher values = slower to start/stop.

These combine to create natural, organic motion that feels more lifelike than fixed-duration transitions.

Using Config Presets

React Spring provides named presets so you don't need to tweak raw numbers:

import { useSpring, animated, config } from '@react-spring/web';

const MyComponent = () => {
  const styles = useSpring({
    from: { opacity: 0 },
    to: { opacity: 1 },
    config: config.wobbly // Preset configuration
  });

  return <animated.div style={styles}>Bouncy!</animated.div>;
};

Available presets: config.default, config.gentle, config.wobbly, config.stiff, config.slow, config.molasses.

Custom Configuration

For precise control, pass an object:

const styles = useSpring({
  from: { scale: 0 },
  to: { scale: 1 },
  config: {
    tension: 280,
    friction: 60,
    mass: 2
  }
});

Analogy: Think of a door closer. Tension is how strong the spring pulls, friction is how much oil dampens it, and mass is how heavy the door is.

When to Customize

  • Use presets for quick, good-enough motion
  • Customize when you need specific feel (e.g., heavier UI elements, ultra-snappy feedback)
  • Test multiple configs — small changes dramatically affect perceived quality

Key Takeaway: React Spring's config prop lets you choose preset physics (config.wobbly) or fine-tune tension, friction, and mass for precise, natural animation feel.