CSS Animated Gradient Border
A border beam card: a conic gradient spins behind a masked edge so the border light travels around the card.

An animated gradient border, often called a border beam, is a thin band of color that travels around a card. Product sites use it on featured plans, live status tiles, and “new” callouts because the edge moves while the type stays still.
The beam is a conic-gradient on a pseudo-element. The card face sits on top and covers the middle, so only a 1–2px ring of the gradient remains visible. @property --angle lets the browser interpolate the gradient angle on the compositor.
This sits next to the spotlight card and the glowing gradient cards. The spotlight follows the pointer. The beam loops on its own.
Where an animated gradient border belongs
Use one beam on the card you want read first: a recommended price, a selected integration, a live incident. A grid of twelve spinning borders turns into noise. Three speeds in the demo show the same mask with different color stops: a cool violet loop, a warm copper loop, and a faster status loop.
Keep body copy off the border itself. The light is a frame. The sentence lives on the solid face, where contrast stays stable.
HTML for the border beam card
The face is a child, not a background on the same element. That split is what creates the ring.
<article class="beam" style="--c1:#67e8f9; --c2:#a78bfa; --c3:#f0abfc; --speed:4.2s">
<div class="beam__face">
<h2>Quiet edge</h2>
<p>A conic gradient rotates behind the card.</p>
</div>
</article>
CSS for the spinning gradient border
Register the angle so it can animate. The pseudo-element is oversized and masked by the face’s background.
@property --angle {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
.beam {
position: relative;
border-radius: 28px;
padding: 1.5px;
overflow: hidden;
isolation: isolate;
}
.beam::before {
content: "";
position: absolute;
inset: -60%;
z-index: -2;
background: conic-gradient(
from var(--angle),
transparent 0 62%,
var(--c1), var(--c2), var(--c3),
transparent 88%
);
animation: spin var(--speed, 4.5s) linear infinite;
}
.beam__face {
position: relative;
border-radius: 26px;
background: #14121a;
padding: 1.35rem 1.2rem;
}
@keyframes spin {
to { --angle: 360deg; }
}
padding: 1.5px is the border thickness. A larger padding makes a thicker beam. inset: -60% gives the conic gradient room to rotate without the transparent gap sitting in the corner.
If you need a fallback where @property is missing, rotate the pseudo-element with transform: rotate(1turn) instead of animating --angle. The edge will still travel. The gradient will rotate as a bitmap, which is slightly softer.
Accessibility
The animation is decorative. Under prefers-reduced-motion: reduce, stop the spin and leave a static conic ring so the card still looks framed. Do not put the only “selected” signal in the motion. Add text, a check, or aria-current.
The face background is solid #14121a with near-white type. Test that pair. A translucent face looks richer and fails contrast as soon as the beam passes behind a letter.
Questions about CSS gradient borders
How do I animate a gradient border in CSS?
Paint a conic-gradient on ::before, animate its angle with @property, and cover the center with a child that has a solid background and a slightly smaller radius. The visible remainder is the animated border.
Why does my gradient border not rotate?
A custom property is not animatable until you register it. Add @property --angle with syntax: "<angle>". Without that rule, keyframes set the variable at the end and the border jumps once.
Can I pause the border beam on hover?
Yes. animation-play-state: paused on :hover holds the light where the pointer entered. Use that on dense cards so the loop does not compete with reading.