Glow border button
Animated gradient border button in CSS: a conic-gradient runs around a dark pill on hover, driven by @property. No JavaScript.
The border is the button's own background: 1px of padding around a conic-gradient whose start angle is the custom property --gbb-angle. An @property rule registers that variable as an <angle>, which lets the gbb-spin keyframes animate it from 0deg to 360deg over four seconds. An inner span with a solid fill covers everything except the 1px ring, so only the gradient edge shows. The animation starts paused and runs on :hover and :focus-visible, where a soft box-shadow glow also appears, and prefers-reduced-motion turns it off.
snippet.html45 lines
<button class="gbb" type="button">
<span class="gbb__label">Get started</span>
</button>
<style>
@property --gbb-angle {
syntax: "<angle>";
initial-value: 0deg;
inherits: false;
}
.gbb {
--gbb-bg: #111;
--gbb-text: #f5f5f5;
--gbb-glow-a: #7c5cff;
--gbb-glow-b: #22d3ee;
position: relative;
padding: 1px;
border: 0;
border-radius: 999px;
background: conic-gradient(from var(--gbb-angle), #2a2a2a 0deg, #2a2a2a 200deg, var(--gbb-glow-a) 260deg, var(--gbb-glow-b) 320deg, #2a2a2a 360deg);
cursor: pointer;
font: 500 15px/1 ui-sans-serif, system-ui, sans-serif;
transition: box-shadow 0.3s ease;
animation: gbb-spin 4s linear infinite paused;
}
.gbb:hover,
.gbb:focus-visible {
animation-play-state: running;
box-shadow: 0 0 24px -6px var(--gbb-glow-a);
outline: none;
}
.gbb__label {
display: block;
padding: 14px 28px;
border-radius: inherit;
background: var(--gbb-bg);
color: var(--gbb-text);
}
@keyframes gbb-spin {
to { --gbb-angle: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
.gbb { animation: none; }
}
</style>