Journal / CSS

← All posts

Gradients thatfinally animate

PostedApr 2026Read3 minByYevhenii Nebenzia
A red to black gradient card with @property code

For years, animating a gradient in CSS was a trick. CSS @property turns it into one line of transition.

The old way was to stack two divs with different gradients and fade one in while the other faded out. It worked, but it meant two layers, extra markup and a change that never quite felt like one gradient moving.

CSS @property lets you register a custom property with a type. Once the browser knows a variable is a colour, it knows how to animate it.

@property --c1 { syntax: '<color>'; inherits: false; initial-value: #6b0c15; }
@property --c2 { syntax: '<color>'; inherits: false; initial-value: #0b0b0c; }

.card {
  background: linear-gradient(135deg, var(--c1), var(--c2));
  transition: --c1 .8s, --c2 .8s;
}
.card:hover { --c1: #ecd5d6; --c2: #6b0c15; }

Live demo, built with the code above

Where we use it

Hover states on cards, background shifts between sections and slow gradients in heroes. It works with angles and percentages too: register a variable as an angle and you can rotate a conic gradient without any JavaScript.

In Webflow

Add the @property rules in the site head or a code embed, then set the variables on your classes. Current Chrome, Safari and Firefox all support it.