A short beam of light travels the edge of a dark box over a faint track, the look from AI and developer tool sites. A narrow conic arc on an @property angle, masked to the edge and given a glow.
Also known as: border beam css, moving border animation, light running around border.
<div class="bdr-border-beam"><span class="bdr-border-beam-light"></span>Border beam</div>
@property --bdr-border-beam-a {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
.bdr-border-beam {
--c: var(--bdr-color, #3b82f6);
font-size: var(--bdr-size, 16px);
position: relative;
display: grid;
place-items: center;
width: 15em;
height: 8.5em;
border-radius: 1em;
font-family: system-ui, sans-serif;
font-weight: 600;
background: color-mix(in srgb, var(--c) 10%, #0b0f19);
box-shadow: inset 0 0 0 1px color-mix(in srgb, #fff 12%, transparent);
color: #f1f5f9;
}
.bdr-border-beam-light {
position: absolute;
inset: 0;
border-radius: inherit;
filter: drop-shadow(0 0 0.25em var(--c));
pointer-events: none;
}
.bdr-border-beam-light::before {
content: "";
position: absolute;
inset: 0;
padding: 0.14em;
border-radius: inherit;
background: conic-gradient(from var(--bdr-border-beam-a), transparent 0 74%, color-mix(in srgb, var(--c) 60%, transparent) 86%, var(--c) 94%, color-mix(in srgb, var(--c) 25%, #fff) 98.5%, transparent 99%);
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
animation: bdr-border-beam-orbit 3s linear infinite;
}
@keyframes bdr-border-beam-orbit {
to { --bdr-border-beam-a: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
.bdr-border-beam, .bdr-border-beam *, .bdr-border-beam::before, .bdr-border-beam::after, .bdr-border-beam *::before, .bdr-border-beam *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--bdr-color on the element or a parent.
Currently previewing #3b82f6.--bdr-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.