Skip to content
Tutorials Center
My learning

Topics

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).

CSS
.panel {
  transition: transform 400ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

Try it

Compare easing curves

The red dot passes its end point and comes back, because the second y value is above 1.

Syntax

CSS
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-function and the transition / animation shorthands. 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 y1 with small x1 means a fast start; a small y2 with large x2 means 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 opacity is clamped when it paints).
  • Per keyframe. In @keyframes, animation-timing-function set 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 use steps().
  • Tools. Browser DevTools have a curve editor for dragging the control points visually.

Browser support

Supported in all browsers.