Why springs feel better than easing curves for UI toggles

November 14, 2026 · 7 min read

Click a toggle, then click it again before it finishes moving. With a typical CSS transition, one of two things happens: the knob snaps to its starting point and restarts, or it finishes the old trip and only then turns around. Both feel slightly wrong, and people notice even when they cannot say why. Springs solve this problem at the root, and they are worth understanding before you reach for another cubic-bezier.

Easing curves have a fixed script

A duration-based animation is a script. You say "take 200 milliseconds to go from here to there along this curve", and the browser plays it back. The script knows nothing about what the element was doing a moment ago. If you change the target mid-flight, the animation has to either restart from the current position with a brand new script or ignore you until it is done.

That is fine for a page transition that plays once. It is a poor fit for controls that people poke repeatedly, such as switches, tabs, sliders and menus.

A spring is a rule, not a script

A spring animation does not have a duration. It is a small physics simulation: the value is pulled toward its target by a force, and a damping force slows it down. Every frame the simulation updates the position and the velocity. When you change the target, the spring simply starts pulling toward the new one, and the current velocity carries over. Nothing restarts, so a quick double click produces a smooth reversal instead of a glitch.

Three numbers define the behaviour:

  • Stiffness: how hard the spring pulls toward the target. Higher values are snappier. For small controls, 400 to 600 works well.
  • Damping: how quickly motion is absorbed. Low damping overshoots and wobbles, high damping feels heavy. For toggles, 30 to 40 is a good range.
  • Mass: how heavy the object is. Most UI work leaves it at 1 and tunes the other two.

If you only remember one rule: raise stiffness to make it faster, raise damping to make it calmer. A stiffness of 500 with damping of 34 gives a quick move with a tiny, pleasant settle.

Building a spring switch with Motion

Motion (the successor to Framer Motion) lets you describe the end state and pick a spring transition. For a switch you only need to move the knob between two positions. Using the layout prop means you do not have to measure anything: you change which side the knob sits on and Motion animates the difference.

spring-toggle.tsx
"use client"

import { useState } from "react"
import { motion } from "motion/react"

export function Toggle() {
  const [on, setOn] = useState(false)

  return (
    <button
      type="button"
      role="switch"
      aria-checked={on}
      onClick={() => setOn((v) => !v)}
      className={
        "flex h-8 w-14 items-center rounded-full p-1 transition-colors " +
        (on ? "justify-end bg-emerald-500" : "justify-start bg-neutral-300")
      }
    >
      <motion.span
        layout
        transition={{ type: "spring", stiffness: 500, damping: 34 }}
        className="size-6 rounded-full bg-white shadow"
      />
    </button>
  )
}

That is the whole trick. The knob moves because flexbox moves it, and layout animates that move with a spring. Click it rapidly and you will see it reverse smoothly from wherever it is.

Do not forget the semantics

A toggle is not just an animation. Use a real button element so it is focusable and responds to Space and Enter. Give it role="switch" and keep aria-checked in sync with the state, so screen readers announce "on" and "off" instead of "button". If the switch has a visible label, connect it with aria-labelledby, or give the button an aria-label.

Tuning by feel

Spend two minutes on tuning. Change one number at a time and click the control ten times quickly. If it feels sluggish, raise stiffness. If it feels wobbly or toy-like, raise damping. If the overshoot is visible on a tiny control, it is probably too much: toggles want a settle you almost cannot see.

It also helps to match the spring to the size of the move. A large panel sliding across the screen can afford a softer spring than a 20-pixel knob. Keep related controls on the same spring so the interface feels like one material.

When to stay with easing

Springs are not always better. Colour and opacity changes have no sense of momentum, so a short ease-out transition is the right tool. Choreographed sequences where timing matters, such as a loading animation synced to audio, want exact durations. Use springs for things that move in response to the user, and easing for things that simply change.

If you want the finished result without writing it yourself, the Spring Switch component on makeui packages this exact approach with keyboard support and reduced-motion handling built in.

Related component

Spring Switch

An accessible toggle switch for React with a spring thumb and a press-down feel. Keyboard and screen reader friendly.

See the component

More guides