What You'll Learn
You'll learn how to control the speed curve of CSS transitions using easing functions, making animations feel more natural and polished.
What Is transition-timing-function?
The transition-timing-function property determines how an animation progresses from start to finish. Instead of just setting how long it takes (that's transition-duration), this property controls whether the animation moves at a constant speed, starts slow and speeds up, or follows other patterns.
Think of it like driving a car: you don't instantly go from 0 to 60 mph and then instantly stop. You accelerate gradually, cruise, then brake. The timing function controls that acceleration curve.
Common Easing Functions
linear – The animation moves at a constant speed from start to finish. Like a robot's movement: perfectly steady but a bit unnatural.
.box {
transition-timing-function: linear;
}
ease – The default. Starts slowly, speeds up in the middle, then slows down at the end. Natural and smooth for most transitions.
ease-in – Starts slowly, then accelerates. Like a car pulling away from a stoplight.
ease-out – Starts quickly, then decelerates. Like a car braking to a smooth stop.
ease-in-out – Similar to ease, but with more pronounced slow starts and ends. Symmetrical acceleration and deceleration.
.button {
transition-property: transform;
transition-duration: 0.3s;
transition-timing-function: ease-out; /* Quick start, smooth landing */
}
Choosing the Right Function
Use ease-out for UI elements entering the screen (they arrive quickly and settle). Use ease-in for elements exiting (they leave decisively). Use linear sparingly—it often feels mechanical.
Key Takeaway: The transition-timing-function property controls the acceleration curve of your animations using easing functions like ease, linear, ease-in, ease-out, and ease-in-out, making transitions feel more natural and intentional.