Skip to content
StackD

· Arnau López

Motion design for UI components: the rules I use

Most interfaces either don't move at all, or move everything: cards that float, buttons that glow, numbers that count up every time you scroll past them. Both feel off. One feels dead, the other feels like a demo.

Every component in StackD moves, so I had to decide how. These are the rules I ended up with. None of them are new. They come from animation and from apps that feel good to use. But writing them down is what keeps the components feeling like one set.

1. Move when something happens

Motion should answer something: you pointed, you pressed, you dragged, new data arrived. If nothing happened, nothing should move. A card that bobs up and down forever is asking for attention it didn't earn.

The one exception is when the motion is the information. A live dashboard can move on its own, because the movement means “this is happening right now”.

2. Use springs, not ease-in-out

Real things don't stop dead. They go a little past where they're going and settle back. You can get that with a cubic-bezier whose second value is above 1:

.press {
  transition: transform 420ms cubic-bezier(.34, 1.8, .5, 1);
}
.press:active {
  transform: scale(.92, .88);
  transition-duration: 90ms; /* going in is fast, coming back is springy */
}

The 1.8 is the overshoot. Higher feels like jelly, closer to 1 feels calmer. Pick one or two curves and use them everywhere, like you would with colours.

3. Squash and stretch, a little

This one is from cartoons. When something lands or gets pressed, it squashes wide and short, then stretches back before it settles. It makes things feel soft instead of rigid. The trick is to keep it small: a few percent, not a rubber ball.

@keyframes squish {
  0%   { transform: scale(1) }
  30%  { transform: scale(1.18, .78) }
  60%  { transform: scale(.92, 1.1) }
  100% { transform: scale(1) }
}

4. Start where the user is

When you point at something, it should react first and the things around it a little after. In the Hex performance card, the hexagon you point at lifts and its neighbours shrink to make room. When the range changes, the colours change in a wave from the middle, not all at once.

The wave is just a delay that grows with the distance from the centre, the furthest one waiting 460 ms:

style={{ transitionDelay: `${(distance / maxDistance) * 460}ms` }}

5. Let motion explain the data

This is the rule I like most. In the Hex dashboard, the funnel isn't only a shape. Shoppers flow through it as small dots, and at each step some of them fall away. You don't need to read “53%” to feel that half of them left: you see it.

Hex dashboard, a StackD template with a live funnel and a hexagon radar

The same goes for the radar next to it. Drag a metric onto a corner and the shape springs into its new form, so you see what changed instead of just reading a new number.

6. Keep it cheap

Motion that makes the laptop fan spin is worse than no motion. A few rules that keep it light:

  • Animate transform and opacity. Avoid animating width, height or top.
  • Lots of small moving things (like the funnel's dots) go in one canvas, not hundreds of elements.
  • Stop what's off screen. An IntersectionObserver is enough.
  • Watch out for 3D CSS. It can create GPU layers even when you don't see any 3D.

I learned that last one the hard way: How 3D CSS made my component store slow.

7. Respect “reduce motion”

Some people get dizzy from motion, and they tell their system so. Listen to it. The components should still work, just without the springs:

@media (prefers-reduced-motion: reduce) {
  .squish, .lift, .ripple { animation: none !important; }
}

A quick check before you ship

  • Is anything moving while nobody is doing anything? Does it need to?
  • Do your springs all use the same one or two curves?
  • Does the thing you touched react first, and the rest after?
  • Does any motion tell you something about the data, or is it only decoration?
  • Turn on reduce motion and use the page once.

If you want to see these rules in real components, everything in the StackD store is live: point, press and drag.