CSS propertyTransitions

transition-timing-function

Sets the transition’s easing curve: accelerating, decelerating, or stepped motion.

Initial value
ease
Inherited
No
Animatable
no
Applies to
all elements and the ::before and ::after pseudo-elements
JavaScript
element.style.transitionTimingFunction = "ease-out"
On this page

Example

#
CSS
.drawer {
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
Preview

Definition and usage

#

The transition-timing-function property decides how the pace of change is distributed over time. linear changes the value evenly, ease-in starts slowly and speeds up, ease-out starts fast and slows down, and ease-in-out combines both.

A custom curve is described by the cubic-bezier() function. Values outside the 0-1 range create an overshoot and spring effect. The steps() function splits the transition into discrete steps, like frame-by-frame animation.

The newer linear() function lets you write an arbitrarily complex curve as a list of points, for example a realistic bounce.

Syntax

#
Syntax
transition-timing-function: ease | linear | ease-in | ease-out | ease-in-out | steps(…) | cubic-bezier(…) | linear(…);

Values

#

Values in practice

#

ease

A gentle start, a fast middle, a gentle finish.
.demo { transition-timing-function: ease; }

linear

A constant pace from start to finish.
.demo { transition-timing-function: linear; }

ease-in

A slow start that speeds up.
.demo { transition-timing-function: ease-in; }

ease-out

A fast start that slows down.
.demo { transition-timing-function: ease-out; }

steps(4)

Four discrete steps instead of smooth motion.
.demo { transition-timing-function: steps(4); }

cubic-bezier(.34, 1.56, .64, 1)

A slight overshoot of the target and a return.
.demo { transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Elements appearing on screen usually look best with ease-out, and disappearing ones with ease-in.
  • You can easily tune cubic-bezier() curves in the browser’s developer tools by clicking the icon next to the value.

Related entries

#

Practise it in lessons

#

Spotted a mistake or missing an example? Write to us.