How it works
A beam from a spinning gradient and a ring mask
Nothing travels along the border. A conic gradient, a wedge of color around the center of the box, turns in place, and a mask hides everything but the border. Where the wedge crosses the border, it looks like light running around it.
1. The ring: mask-composite exclude
A layer covers the card's border box and gets the border width as its padding. Its mask has
two layers of the same solid image: one clipped to the content-box, one
covering everything. mask-composite: exclude keeps only the parts where exactly
one of the two is opaque, which is the padding: a ring as wide as the border, with corners
that follow border-radius on both edges. Whatever is painted into the layer only shows in
the ring. The spotlight cards use the same mask for their
glowing borders.
The ring sits at z-index: -1 inside an isolation: isolate card, so it
paints above the card's background and plain border but below the text.
<div class="card">
<span class="glow" aria-hidden="true"><span class="ring"></span></span>
<span class="ring" aria-hidden="true"></span>
…content…
</div> 2. The beam: a conic gradient with a moving start
conic-gradient() sweeps its colors around a center point instead of along a
line. Most of the circle here is transparent; the last stretch of the turn fades from
transparent through the tail color to the head color. from <angle> rotates
the whole gradient. Animate that angle from 0 to 360deg and the bright wedge circles the center,
which on the ring reads as a beam.
A gradient can't be animated directly, and neither can a normal custom property: the browser
only sees tokens and flips from one value to the other halfway through. Registering the
property with @property and syntax: '<angle>' tells it what
lies between 0deg and 360deg, so the angle, and the gradient using it, is interpolated on
every frame. The aurora page shows the difference side by side.
Two details. The gradient has to be written on the ring itself, not on the card: a custom
property that contains var() is resolved where it is declared, so a gradient
defined on the card would freeze the card's (unanimated) angle into it. And the property
does not inherit, so only the ring is restyled each frame, not the card's
content. Several beams use repeating-conic-gradient with a period of 360° divided
by the count.
This is the CSS for your current settings:
@property --angle {
syntax: '<angle>';
inherits: false;
initial-value: 0deg;
}
.card {
position: relative;
isolation: isolate;
border: 2px solid color-mix(in oklab, currentColor 12%, transparent);
border-radius: 18px;
}
/* covers the border box; only its padding (= the border) survives the mask */
.card > .ring, .card > .glow {
position: absolute;
inset: -2px;
z-index: -1;
border-radius: inherit;
pointer-events: none;
}
.ring {
padding: 2px;
mask:
linear-gradient(#000 0 0) content-box exclude,
linear-gradient(#000 0 0);
background: conic-gradient(#67e8f9, #a855f7, #67e8f9);
}
/* a blurred copy: the filter is on the wrapper, so it blurs the masked ring */
.glow { filter: blur(12px); opacity: 0.7; }
.glow > .ring { position: absolute; inset: 0; border-radius: inherit; }
@media (prefers-reduced-motion: no-preference) {
.ring {
background: conic-gradient(from var(--angle), transparent 0deg 270deg, #a855f7 310.5deg, #67e8f9 357deg, transparent 360deg);
animation: spin 5s linear infinite;
}
}
@keyframes spin { to { --angle: 360deg; } } 3. Glow
The glow is a second ring, blurred. The blur has to be on a wrapper around it: CSS applies
an element's filter before its mask, so a blur on the masked ring
itself would be cut back to the ring's sharp edges. On the wrapper, the already masked ring
is blurred and spills softly inside and outside the border. At a glow of 0 the copy isn't
rendered at all, which saves a filter pass.
4. Why the beam changes length
The beam length is an angle around the center, not a distance along the border. One degree
covers little border where the border is close to the center and a lot where it is far away,
or where it runs at a slant to the center, near the corners. On a wide card the beam is
shortest and slowest in the middle of the long sides and stretches and speeds up towards the
corners. Only on a square or a circle does it stay even. Constant speed would need a
path-based technique (for example offset-path with a blurred dot), which can't use
the ring mask and doesn't follow arbitrary radii as easily.
Motion and accessibility
- Under
prefers-reduced-motion: reduce, and with Animate off, the border shows a still ring with both colors once around, instead of a beam parked in one spot. The Pause animations button freezes the beam where it is (WCAG 2.2.2). - The current settings pass any point of the border 0.2 times per second. Keep it well below three for bright, short beams, so the beam never reads as flashing.
- The ring layers are
aria-hiddenand ignore the pointer. The content is ordinary markup; the button in the demo is a real button inside the beam, and its focus ring is not clipped (nothing here usesoverflow: hidden).
Browser support
Conic gradients have been Baseline widely available since 2023-05-17, CSS masks (including mask-composite) since 2026-06-07, and @property is Baseline newly
available since 2024-07-09 (Chrome 85, Safari 16.4, Firefox 128), per web-features 3.44.0.
Without @property the angle would not interpolate and the beam would sit still
at the top; the component checks for CSS.registerProperty after mount and shows the
still two-color ring instead. Tested in Chromium 156 only; Firefox and Safari are untested.
Performance notes
- The ring repaints every frame. Changing a gradient's angle is a paint, not a compositor-only change. The painted area is only the ring layers, though, and the content is untouched because the property doesn't inherit. A handful of beams on a page is cheap; a grid of hundreds is not (judgment).
- The glow costs a blur over the card's area. Its cost grows with the blur radius. Turn it off for long lists of beam cards.
- Paused or reduced motion, nothing repaints.