CSS animation-composition Property

The animation-composition property determines how a CSS animation's values combine with the existing values of the properties being animated.

It supports three operations: replace, add, and accumulate. These control whether an animation replaces an underlying value or combines its effect with that value. The property is especially useful when multiple animations affect the same CSS property.

animation-composition Syntax

selector {
  animation-composition: replace;
}

Replace replace with add or accumulate to change how the animation effect combines with the underlying property value.

For elements running multiple animations, specify a comma-separated list of composition values.

.animated-element {
  animation-composition: add, accumulate;
}

The property also accepts the global CSS values inherit, initial, revert, revert-layer, and unset.

Property Values

Value Description
replace Replaces the underlying property value with the animation's effect value. This is the initial value.
add Adds the animation's effect to the underlying value using the property's addition operation.
accumulate Combines the animation's effect with the underlying value using the property's accumulation operation.

The property applies to all elements, is not inherited, and has an initial value of replace. Its computed value is the specified list of composition keywords.

The animation-composition property itself is not animatable. It controls how other animated properties are combined.

How animation-composition Works

When CSS animates a property, the browser determines how the animation's value interacts with the value already assigned to that property.

The existing value is called the underlying value, while the value supplied by the animation is called the effect value.

By default, an animation replaces the underlying value while its effect applies.

.box {
  transform: rotate(20deg);
  animation: move-box 2s linear infinite alternate;
  animation-composition: replace;
}
@keyframes move-box {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100px);
  }
}

In this example, the animated transform replaces the element's original rotation while the animation runs.

Changing animation-composition to add or accumulate allows the animation to combine with the existing transform instead.

The exact result depends on the animation type of the CSS property. For some values, addition and accumulation produce the same result. For others, such as transform lists and filter functions, they can behave differently.

Replace, Add, and Accumulate

The three composition values are easiest to compare using a CSS filter.

Suppose an element has an underlying blur of 2px and an animation supplies a blur of 3px.

Using replace

.replace-example {
  filter: blur(2px);
  animation: blur-effect 2s linear infinite alternate;
  animation-composition: replace;
}
@keyframes blur-effect {
  from {
    filter: blur(3px);
  }
  to {
    filter: blur(6px);
  }
}

At the first keyframe, replace uses blur(3px) instead of the underlying blur(2px).

Using add

.add-example {
  filter: blur(2px);
  animation: blur-effect 2s linear infinite alternate;
  animation-composition: add;
}

At the first keyframe, add appends the animated filter to the existing filter, producing the equivalent of blur(2px) blur(3px).

Using accumulate

.accumulate-example {
  filter: blur(2px);
  animation: blur-effect 2s linear infinite alternate;
  animation-composition: accumulate;
}

At the first keyframe, accumulate combines the blur values into blur(5px).

Although both add and accumulate preserve the underlying effect, they use different composition operations. Their results are not necessarily interchangeable.

Multiple Animations

When an element has several animations, you can assign a different composition operation to each animation.

.animated-box {
  animation: move-box 3s linear infinite alternate, rotate-box 3s linear infinite;
  animation-composition: add, accumulate;
}

The first composition value, add, applies to move-box. The second, accumulate, applies to rotate-box.

Composition values are matched to animations in the order specified by animation-name. If there are fewer composition values than animations, the browser repeats the list as needed.

.three-animations {
  animation-name: move, rotate, scale-up;
  animation-composition: replace, add;
}

Here, move uses replace, rotate uses add, and scale-up uses replace because the composition list repeats.

When animations affect the same property, their effects are combined in the animation effect stack. The order of those effects can influence the final result.

Composing Transform Values

The difference between add and accumulate is particularly important when working with the transform property.

Consider an element with an existing rotation:

.box {
  transform: rotate(30deg);
}
@keyframes slide {
  to {
    transform: translateX(100px);
  }
}

At the final keyframe, the three composition operations produce different results:

Value Result at the Final Keyframe
replace The animation replaces the rotation with translateX(100px).
add The transforms are concatenated as rotate(30deg) translateX(100px), so the translation follows the rotated coordinate system.
accumulate The translation components are combined while retaining the rotation, producing a different transform from the additive result.

This distinction matters when an element needs to retain an existing transformation while another animation changes its position, rotation, or scale.

Transform composition can be more complex than combining simple numeric values because the order and type of transform functions affect the result.

animation-composition Example

The following example compares the three composition values using an underlying blur filter and an animated blur effect.

<div class="composition-demo">
  <div class="composition-item replace">
    <strong>Replace</strong>
    <span>CSS</span>
  </div>
  <div class="composition-item add">
    <strong>Add</strong>
    <span>CSS</span>
  </div>
  <div class="composition-item accumulate">
    <strong>Accumulate</strong>
    <span>CSS</span>
  </div>
</div>
.composition-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.composition-item {
  flex: 1 1 100px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #ccc;
  text-align: center;
}
.composition-item strong {
  display: block;
  margin-bottom: 12px;
}
.composition-item span {
  display: inline-block;
  padding: 12px;
  background-color: #1769aa;
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  filter: blur(2px);
  animation: composition-blur 3s linear infinite alternate;
}
.composition-item.replace span {
  animation-composition: replace;
}
.composition-item.add span {
  animation-composition: add;
}
.composition-item.accumulate span {
  animation-composition: accumulate;
}
@keyframes composition-blur {
  from {
    filter: blur(3px);
  }
  to {
    filter: blur(6px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .composition-item span {
    animation: none;
  }
}

Each label starts with an underlying blur of 2px. The animation supplies values between 3px and 6px, and the composition setting determines how those values are combined.

Browser Result
Replace CSS
Add CSS
Accumulate CSS

The Replace label uses only the animated blur. The Add label applies two blur functions, while the Accumulate label combines their blur radii into one value.

The differences between Add and Accumulate may be subtle for blur effects. They become more noticeable with some transform operations. If reduced motion is enabled, the labels retain their underlying blur without animating.

Important Considerations

Keep the following points in mind when using animation-composition:

  • Default behavior: The initial value is replace, so animations normally override underlying property values while their effects apply.
  • Property animation types: Not every CSS property supports addition or accumulation in the same way. The property's animation type determines the available composition behavior.
  • Animation order: When multiple animations affect the same property, the order of their effects can change the final result.
  • Shorthand declarations: The animation shorthand does not specify animation-composition. Declare composition separately when needed.
  • Reduced motion: Respect the prefers-reduced-motion media feature when creating effects that involve significant movement.

Use replace for ordinary animations that should override existing values. Use add or accumulate when animation effects need to build on existing styles or other animation effects.

Browser Support

The animation-composition property has Baseline Widely available status. It has been supported across major browser engines since July 2023, including modern versions of Chrome, Edge, Firefox, and Safari.

Visit Can I Use? to check current browser compatibility.

When supporting older browsers, remember that unsupported composition declarations are ignored, so animations may use their default replacement behavior.

Specifications

The animation-composition property is defined in the CSS Animations Level 2 specification. Its composition operations follow the model established by the Web Animations specification.

CSS Animations Level 2