# animation-composition

Status: Baseline 2023 (Chrome 112, Safari 16, Firefox 115).  
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/animation-composition  
Page: https://designforai.dev/css/animation-composition

Controls how multiple animations on the same property combine: `add` or `accumulate` instead of the default `replace`. Lets a bob animation ride on top of a rotation without one overwriting the other.

## HTML

```html
<div class="fx-020"></div>
```

## CSS

```css
.fx-020 {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: #ec4899;
  margin: 30px;
    animation: fx-020-spin 3s linear infinite,fx-020-bob 1s ease-in-out infinite alternate;
    animation-composition: replace,add
}
@keyframes fx-020-spin {
  to {
    transform: rotate(360deg)
  }
}
@keyframes fx-020-bob {
  to {
    transform: translateY(-20px)
  }
}
@media (prefers-reduced-motion: reduce) {
  .fx-020, .fx-020 * { animation: none; transition: none; }
}
```

Fallback: Without it, the last animation replaces the first (only the bob plays). Acceptable degradation.

## Prompt

When stacking several keyframe animations on `transform` (or another single property), set `animation-composition: replace, add` (one value per animation) so later animations add to the earlier ones instead of overriding. Alternatively use individual `translate`/`rotate`/`scale` properties, each with its own animation.
