mid · lesson 6 of 8

Animations

CSS, WAAPI, spring physics, choreography.

Sidhanshu Monga·1 min·
You’ll be able to
  1. Choose between CSS transitions, keyframes, WAAPI and springs
  2. Animate properties that stay smooth
  3. Respect reduced-motion preferences

Animation explains change: where something came from, where it went, what just happened. Good animation is quick and purposeful; most users won't notice it, only that the interface feels clear.

Pick the right tool

  • CSS transitions — for changes between two states, like hover or open/closed.
  • CSS keyframes — for looping or multi-step motion, like a spinner or a shimmer.
  • Web Animations API — element.animate() gives you keyframes from JavaScript, with the ability to pause, reverse and await finished.
  • Springs — for motion that should feel physical or respond to gestures. Libraries like Motion provide spring physics.

Animate cheap properties

transform and opacity can usually be animated by the compositor without recalculating layout. Animating width, height, top or left forces layout on every frame and is much more likely to stutter. To animate size or position changes smoothly, measure, then animate a transform (the FLIP technique).

Timing and easing

Most interface transitions sit between about 150 and 300ms. Entering elements should ease out (arrive fast, settle gently); exiting elements can ease in. Compare the curves:

motion
Easing curves
An ease-out moves like a car braking — it settles. A spring feels alive. Linear feels mechanical. Choosing the right curve is choosing how the interface 'breathes'.
cubic-bezier(0.2, 0.7, 0.2, 1)
#choreography#feel
Same distance, same duration, four different curves.

Reduced motion

Some people get dizzy or distracted from motion. Honour prefers-reduced-motion by removing large movement and parallax, while keeping quick fades that still explain the change.

@media (prefers-reduced-motion: reduce) {
  .panel { transition: opacity 150ms linear; transform: none; }
}
Try it

Find one state change in your product that happens instantly (a panel opening, an item being added). Give it a 150–250ms transition on transform and opacity, with an ease-out curve and a reduced-motion fallback. Compare the two versions side by side.

This lesson needs a hands-on exercise. The idea is sketched in issue #66. Build it and it ships here, with your name on it.
Key takeaways
01Animate transform and opacity whenever you can
02Motion should explain a change, not decorate it
03Always provide a reduced-motion path