Register the angle with @property
An ordinary custom property is only text to the browser, so it has no idea what lies between
0degand360deg. Registering it with@propertytells the browser the value is an angle, and that is what makes it animatable.Where the CSS goes: on this site it lives in one Elementor Pro Custom Code snippet (Elementor > Custom Code, location
<head>, wrapped in a<style>tag). Without Elementor Pro, paste it into Appearance > Customize > Additional CSS, or into your child theme'sstyle.css.
Registering the property is what gives the browser values in between to draw. spinning-border.cssCSS @property --edge-angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }The MDN reference puts the purpose of the at-rule in one line:
The @property CSS at-rule is used to explicitly define CSS custom properties
MDN Web Docs, @property reference "Explicitly" is the important word. Until a property is defined with a syntax, the browser treats it as a string, and a string cannot be part-way between two values. Defining it as an
<angle>is the whole trick; everything after this step is ordinary CSS.Paint the gradient on the border box
The element gets two backgrounds. The first is a solid fill clipped to the
padding-box, the area inside the border. The second is aconic-gradient()clipped to theborder-box, so only the 2px ring round the edge shows it. The transparent border makes room for that ring, and because it is a real border,border-radiusrounds it with no extra work.Match the solid fill to the colour behind the element. Here it is the panel colour
#131322from the Test365i design system. The gradient startsfrom var(--edge-angle), which is the value the next step turns.
Two backgrounds, two boxes: the fill covers everything except the 2px border. spinning-border.cssCSS .spin-edge { border: 2px solid transparent; background: linear-gradient(#131322, #131322) padding-box, conic-gradient(from var(--edge-angle), #7453FE, #35D0FF, #F93CBB, #7453FE) border-box; animation: edge-spin 4s linear infinite; }After step 2: the gradient ring is in place, standing still because nothing turns the angle yet. Turn the angle with @keyframes
One keyframe is enough. The
animationline in step 2 runs it every four seconds, at a steady speed, for ever. Because the angle is registered, the browser draws every position between 0 and 360 degrees instead of jumping from start to end.When I built this site, Elementor 4 did not keep animation properties inside a global class, so this keyframe sits in the same Custom Code snippet as step 1. Keep the two together and the class itself stays a plain style.
spinning-border.cssCSS @keyframes edge-spin { to { --edge-angle: 360deg; } }After step 3: the angle turns once every four seconds, so the edge spins. Una Kravets of the Chrome team described the gap this fills when she introduced the feature on web.dev:
There's no way to smoothly animate (or interpolate) between gradient values
Una Kravets, web.dev, "@property: giving superpowers to CSS variables" That is why the gradient itself never animates here. Its colours stay fixed and only the registered angle moves, which the browser can interpolate. Older versions of this effect rotated an extra, oversized layer behind the button and hid the overflow; registering the angle removes that layer completely.
Add the spin-edge class in Elementor 4
Select the button or container, open the Style tab and add
spin-edgeas a class. Elementor 4 prints a global class under the name you give it, so the CSS above finds the element with no extra selector. On this site the same class gives 20 buttons and panels across seven pages their moving edge, including the frames in the Elementor 4 element gallery.Outside Elementor, add the class to any element in your HTML:

One class turns any button or panel into a spinning edge. index.htmlHTML <a class="spin-edge" href="/contact/">Talk to us</a>Stop the spin for people who prefer less motion
Some visitors ask their device to reduce motion. This media query stops the turn for them and leaves a still gradient edge, which still looks finished. It is the same rule that calms the animated aurora background on this site.
spinning-border.cssCSS @media (prefers-reduced-motion: reduce) { .spin-edge { animation: none; } }The finished border. With Reduce motion on in your device settings, the edge holds still.
What the spinning gradient border does not do
Browsers without @property show the gradient standing still. Chrome and Edge 85, Safari 16.4 and Firefox 128 and later all animate it.
The padding-box fill must be a solid colour, so the edge suits elements on a plain background, not a button sitting over a photo.
Animating a custom property repaints the element on every frame. It is fine for a handful of buttons and panels, as on this site, but I would not put it on every card in a long grid.
All the spinning gradient border code
Each file below is complete. Copy it, or download it under the name shown.
@property --edge-angle {
syntax: '<angle>';
inherits: false;
initial-value: 0deg;
}
.spin-edge {
border: 2px solid transparent;
background:
linear-gradient(#131322, #131322) padding-box,
conic-gradient(from var(--edge-angle), #7453FE, #35D0FF, #F93CBB, #7453FE) border-box;
animation: edge-spin 4s linear infinite;
}
@keyframes edge-spin {
to { --edge-angle: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
.spin-edge { animation: none; }
}<a class="spin-edge" href="/contact/">Talk to us</a>Spinning gradient border questions
Does a spinning gradient border need JavaScript?
No. The angle is registered with @property and turned by a CSS keyframe, so it runs with JavaScript switched off.
Which browsers support CSS @property?
Chrome and Edge from version 85, Safari from 16.4 and Firefox from 128. Older browsers ignore the registration and show the same gradient border standing still, so nothing breaks.
Can I use this in Elementor without Elementor Pro?
Yes. Elementor Pro gives you the Custom Code screen used on this site, but the same CSS works in Appearance > Customize > Additional CSS or a child theme stylesheet. In Elementor you only add the class.
How do I change the colours or the speed?
Change the colour stops inside conic-gradient(), keeping the first and last the same so the loop has no seam. Change 4s in the animation line: a higher number turns more slowly.
Will it work on a card or a panel, not just a button?
Yes. The class works on any element with a solid background. Give panels a larger border-radius, as the demo does.
Does the animation affect Core Web Vitals?
It does not move anything, so it adds no layout shift. It repaints the element each frame, so keep it to a few accents rather than dozens of elements.
Can I add a glow as well?
Yes. A soft box-shadow in one of the gradient colours sits well behind the ring. Box Shadow Generator, made by Mark McNeece of 365i, builds one you can copy.