Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Transforms, Transitions and Animations

The animation-composition property

Reference for the CSS animation-composition property: replace, add and accumulate, how an animation combines with the underlying value, with a live example.

The animation-composition property decides what happens when an animation animates a property that already has a value. Normally the animation replaces that value: the keyframes win, and the base style is ignored while the animation runs. With add or accumulate, the keyframe values are combined with the underlying value instead.

This is most useful when several animations touch the same property, or when a base style such as a transform must be kept while an animation adds movement on top.

CSS
.chip {
  transform: rotate(15deg);
  animation: nudge 1s infinite alternate;
  animation-composition: add;
}

Try it

Replace versus add

The blue bar swings between 20px and 120px because the keyframes replace its width. The other two start at 120px (100px plus 20px) and grow to 220px, because the keyframe values are added to the 100px base.

Syntax

CSS
animation-composition: replace | add | accumulate;

/* one value per animation name */
animation-composition: replace, add;
  • Initial value: replace
  • Applies to: all elements, ::before and ::after
  • Inherited: no
  • Animatable: no
  • Computed value: as specified

Values

Value Description
replace The animated value replaces the underlying value. This is the classic behavior.
add The animated value is added to the underlying value. For lists such as transform, the animation's list is placed after the underlying one, so both apply in sequence.
accumulate Like add, but values of the same type are merged into one, for example two rotations become a single combined rotation.

Usage notes

  • add and accumulate look identical for simple numbers and lengths. They differ for list-like values such as transform and filter: add appends functions, accumulate combines matching functions into one.
  • Order matters for transforms. With add, an underlying rotate(15deg) followed by an animated translateX(100px) moves along the rotated axis. Individual properties such as translate, rotate and scale avoid this problem when you want independent effects.
  • Stacks of animations. When several animations target one property, each animation's composition applies to the result of the animations below it in the list. This lets you layer a hover wobble on top of a base animation.
  • Keyframes can override. A single keyframe may set its own animation-composition inside @keyframes, so one step can add while another replaces.
  • Not for transitions. This property belongs to CSS animations (and the Web Animations API composite option). A transition always replaces.
  • Custom properties. Registered custom properties with a type such as <length> or <number> can be composed as well.

Browser support

Supported in current versions of the major browsers. Because it arrived in 2023, check a compatibility table if you must support older browsers; there, animations simply fall back to replace behavior.