Keyframes

Also called keyframe animation or @keyframes

Snapshots that define how an element looks at set points in an animation. The browser fills in the motion between them.

Keyframes explained

A keyframe pins down an element’s style at one moment of an animation, such as its position, rotation, or opacity at 0%, 50%, and 100% of the way through. The browser works out every frame in between, so a handful of keyframes can describe a path with several turns.

In CSS you write keyframes in an @keyframes rule and attach them with the animation property. In Motion for React you pass an array of values, like x: [0, 100, 0], and an optional times array that says when each value is reached.

Reach for keyframes when an animation needs more than a start and an end: a bounce, a shake, a pulse, or a path with turns. For a simple change from one state to another, a transition is shorter to write and easier to interrupt.

Often confused with

Tweening
Keyframes are the fixed points you define. Tweening is the in-between motion the computer generates from them.
All terms

Tweening

Generating the in-between frames of an animation from a start and an end state, so an element moves smoothly from one to the other.

Shake animation

A quick side-to-side jiggle that tells someone their input was rejected, such as a wrong password or an invalid code.

Looping animation

An animation that plays more than once, either a set number of times or forever, set in CSS with animation-iteration-count.

Easing

A curve that controls how an animation’s speed changes over time, so motion can start slow, land softly, or keep one steady pace.