@property --angle {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
body {
margin: 0;
min-height: 100vh;
display: grid;
place-items: center;
background: radial-gradient(ellipse at top, #1b1d2a, #0a0b10 60%);
color: #f2f3f7;
font: 16px/1.5 system-ui, sans-serif;
}
.hero {
max-width: 34rem;
padding: 2rem;
text-align: center;
}
.hero__badge {
display: inline-block;
margin: 0;
padding: 0.3em 0.8em;
border: 1px solid rgb(255 255 255 / 0.12);
border-radius: 999px;
color: #b8bccb;
font-size: 0.8rem;
}
.hero__title {
margin: 0.8rem 0 0.5rem;
font-size: clamp(2rem, 6vw, 3.2rem);
line-height: 1.05;
letter-spacing: -0.035em;
text-wrap: balance;
}
.hero__text {
margin: 0 auto 1.8rem;
max-width: 28rem;
color: #9aa0b4;
text-wrap: pretty;
}
.hero__actions {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 0.75rem;
}
.btn-ring {
--ring: #7c6cff, #22d3ee, #a3e635, #f472b6, #7c6cff;
position: relative;
isolation: isolate;
display: inline-flex;
align-items: center;
gap: 0.5em;
padding: 0.8em 1.4em;
border: 1px solid transparent;
border-radius: 999px;
background:
linear-gradient(#12131a, #12131a) padding-box,
conic-gradient(from var(--angle), var(--ring)) border-box;
color: #fff;
font-weight: 600;
text-decoration: none;
animation: spin 4s linear infinite;
}
.btn-ring::before {
content: "";
position: absolute;
inset: -2px;
z-index: -1;
border-radius: inherit;
background: conic-gradient(from var(--angle), var(--ring));
filter: blur(16px);
opacity: 0.4;
animation: spin 4s linear infinite;
transition: opacity 0.3s;
}
.btn-ring svg {
transition: transform 0.2s;
}
.btn-ring:hover::before {
opacity: 0.75;
}
.btn-ring:hover svg {
transform: translateX(3px);
}
.btn-quiet {
display: inline-flex;
align-items: center;
padding: 0.8em 1.2em;
border-radius: 999px;
color: #c7cad6;
text-decoration: none;
}
.btn-quiet:hover {
background: rgb(255 255 255 / 0.06);
color: #fff;
}
:is(.btn-ring, .btn-quiet):focus-visible {
outline: 2px solid #fff;
outline-offset: 3px;
}
@keyframes spin {
to {
--angle: 360deg;
}
}
@media (prefers-reduced-motion: reduce) {
.btn-ring,
.btn-ring::before {
animation: none;
}
}How to use it
The rotation animates
--angle, which is registered with @property so the gradient can interpolate. Change the colors in --ring. The border is two backgrounds: a solid padding-box layer over the gradient border-box layer.