CHROMA79

Animated gradient backgrounds with CSS @property

Gradients cannot be transitioned directly, but registered custom properties can. A practical guide to smooth, seamless gradient animation in pure CSS.

Updated 2026-11-16

Why gradients do not animate on their own

Browsers treat a whole gradient as one image value. When a keyframe changes `linear-gradient(90deg, …)` to `linear-gradient(180deg, …)`, there is nothing to interpolate, so the background jumps from one state to the other.

Register the moving part with @property

The fix is to animate a number instead of the gradient. `@property` registers a custom property with a type such as `<angle>`, `<percentage>` or `<color>`. Once the browser knows the type it can tween the value, and the gradient that reads it via `var()` redraws every frame.

@property --angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

.hero {
  background: linear-gradient(var(--angle), #7c3aed, #ec4899, #f97316);
  animation: spin 8s linear infinite;
}

@keyframes spin {
  to { --angle: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
  .hero { animation: none; }
}

Seamless loops

A loop is seamless when the last frame equals the first. For rotations that means whole turns; for back-and-forth motion it means a full sine cycle. CHROMA79 only offers motions that close exactly — spin by whole turns, drift along a figure-eight, pulse and hue shift over full cycles — so the exported CSS and video loop without a jump.

For anything more complex (several layers moving at once, colours shifting, keyframes with easing) CHROMA79 samples the animation and writes one typed property per changing value, dropping keyframes that lie on a straight line so the CSS stays small.

Browser support and accessibility

`@property` works in current Chrome, Edge, Safari and Firefox. Older browsers do not fail: the values still change at each keyframe, they just step instead of tweening. Always switch the animation off for people who prefer reduced motion.