Entry 02
Motion tokens
Use them in every transition and animation. Two easing curves, defined once, and a rule for durations.
--ease-out. Then run the curves. The --ease-out square leaves faster than plain ease-out and settles for longer. The --ease-in-out square waits longer than plain ease-in-out, then crosses the middle faster.
Code
:root {
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
--ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}
.dropdown { transition: opacity 180ms var(--ease-out); }Why it works, the rules and the credits
Why it works
- An ease-out curve starts fast, so the interface moves at the moment the user is watching. Use
--ease-outfor anything entering or leaving. - An ease-in-out curve suits something that is already on screen and moves to a new place. Use
--ease-in-outthere. - The built-in
ease-outandease-in-outkeywords are weak versions of the same shapes. These two are stronger.
Rules
- Never use
ease-inon UI. It starts slow and reads as lag. - Keep a UI transition at 300ms or less. Press feedback takes 100 to 160ms, tooltips and small popovers 125 to 200ms, dropdowns 150 to 250ms. The one exception is a modal or drawer, which takes 200 to 500ms.
- Name the properties in a transition. Never write
transition: all. - Other entries write
var(--ease-out, ease-out), so their snippets work before these tokens exist. - Whether something should animate at all is not a CSS question. Emil Kowalski's
animateandreview-animationsskills answer it.
Support
Every browser.
Credits
Borrowed from: Emil Kowalski, emil-design-eng skill and 7 Practical Animation Tips