Chapter 02 of 11Part 1 · Principles

CSS easing functions and timing

How long UI motion should take, which curve to use for entering and leaving, and how to write your own easing.

10 minBy Zuzo StudioUpdated

10 min

In this chapter you will

  • pick a duration for a movement based on its size and purpose
  • choose between ease-out, ease-in and ease-in-out, and write a custom cubic-bezier()
  • store your durations and curves as custom properties for the project

Before you startThis builds on UI animation principles: why motion?.

Check your understanding

3 questions

Q1A dropdown menu opens when clicked. Which easing fits its entrance best?

Show the answer

ease-out An ease-out moves fastest at the start, so the menu responds at once, and then settles gently into place.

Q2What happens with transition-timing-function: cubic-bezier(0.3, 1.5, 0.6, 1)?

Show the answer

The value overshoots its target and then comes back The y values are progress, and a y value above 1 pushes the value past its end before it settles.

Q3Why might a hover effect use a shorter duration than a dialog opening?

Show the answer

Hover is small, frequent feedback, and slow feedback reads as lag Small, frequent changes should respond almost instantly. A dialog is a larger change the reader needs to follow, so it can take a little longer.

Key takeaways

  1. Most interface motion sits between about 150ms and 500ms, with small and frequent movements at the short end.
  2. Use ease-out for things entering, ease-in for things leaving and ease-in-out for things moving within the screen.
  3. In cubic-bezier() the x values must stay between 0 and 1, while y values outside that range create an overshoot.
  4. linear() can trace springs and bounces with many points, and steps() makes motion jump in frames.
  5. Naming three durations and three curves as custom properties keeps a whole site's motion consistent.
Up next · Chapter 03 · 9 min Staggered animation and sequencing How to offset a group of animations so they read in order, and how to keep the whole reveal under a second.

02FAQ

Questions on this chapter

Something else on your mind? Email the studio and a designer, not a salesperson, replies within a day.

What is the best easing for UI animation?

For most elements entering the screen, an ease-out curve: it responds at once and settles gently. Use ease-in for elements leaving and ease-in-out for elements moving from one place to another on screen.

How long should a CSS transition be?

For interface motion, usually between about 150ms and 400ms. Hover and press feedback sits at the short end, panels and dialogs nearer 300ms, and only large moves across the screen need much more.