CSS Reference ยท Functions
The cubic-bezier() function
Reference for the CSS cubic-bezier() function: how the four numbers shape an easing curve, keyword equivalents, overshoot effects and live examples.
The cubic-bezier() function defines a custom easing curve: how an animation or transition progresses over time. The curve starts at (0, 0) and ends at (1, 1); you place two control points that bend it. Time runs along the x axis and progress along the y axis, so a steep part of the curve means fast movement and a flat part means slow movement.
It is a value for transition-timing-function and animation-timing-function (and the easing option of the Web Animations API).
.panel { transition: transform 400ms cubic-bezier(0.2, 0.8, 0.2, 1); }
Try it
The red dot passes its end point and comes back, because the second y value is above 1.
Syntax
cubic-bezier( <x1>, <y1>, <x2>, <y2> )
The four numbers are the coordinates of the two control points P1 = (x1, y1) and P2 = (x2, y2).
- Where it works:
transition-timing-function,animation-timing-functionand thetransition/animationshorthands. It can also be used per keyframe. - Inherited: not applicable.
- Animatable: no.
Values
| Argument | Description |
|---|---|
x1, x2 |
Must be between 0 and 1 inclusive; values outside make the declaration invalid. |
y1, y2 |
Any number. Below 0 produces a backward "anticipation" move; above 1 produces overshoot. |
The keywords are shorthand for fixed curves:
| Keyword | Equivalent |
|---|---|
linear |
cubic-bezier(0, 0, 1, 1) |
ease (default) |
cubic-bezier(0.25, 0.1, 0.25, 1) |
ease-in |
cubic-bezier(0.42, 0, 1, 1) |
ease-out |
cubic-bezier(0, 0, 0.58, 1) |
ease-in-out |
cubic-bezier(0.42, 0, 0.58, 1) |
Usage notes
- Reading the numbers. The first point controls the start, the second the end. A large
y1with smallx1means a fast start; a smally2with largex2means a slow, soft landing. - Entering things use ease-out, leaving things ease-in. Elements that appear should decelerate; elements that go away can accelerate.
- Overshoot works on any numeric property, but it can make values leave their valid range (for example
opacityis clamped when it paints). - Per keyframe. In
@keyframes,animation-timing-functionset inside a keyframe applies to the segment that starts there, not to the whole animation. - Only a single cubic curve. For bounces or multiple segments use
linear(); for frame-by-frame motion usesteps(). - Tools. Browser DevTools have a curve editor for dragging the control points visually.
Browser support
Supported in all browsers.