Pro plan
Unlimited projects, priority support.
A conic gradient border spins around the card while you hover. The angle is a registered custom property, which is what makes a gradient animatable at all.
Also known as: animated border card, rotating gradient outline, glowing border.
Unlimited projects, priority support.
<article class="hfx-card-gradient-border">
<div class="hfx-card-gradient-border-body">
<h3>Pro plan</h3>
<p>Unlimited projects, priority support.</p>
</div>
</article>@property --hfx-angle {
syntax: "<angle>";
initial-value: 0deg;
inherits: false;
}
.hfx-card-gradient-border {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
width: 15em;
border-radius: 0.75em;
overflow: hidden;
background: #fff;
border: 1px solid color-mix(in srgb, #000 10%, transparent);
color: #1f2937;
font-family: system-ui, sans-serif;
position: relative;
isolation: isolate;
overflow: visible;}
.hfx-card-gradient-border::before {
content: "";
position: absolute;
inset: -2px;
z-index: -1;
border-radius: inherit;
background: conic-gradient(from var(--hfx-angle), var(--c), transparent 35%, transparent 65%, var(--c));
opacity: 0;
transition: opacity 0.3s ease;
}
.hfx-card-gradient-border:hover::before {
opacity: 1;
animation: hfx-card-gradient-border-spin 2.5s linear infinite;
}
.hfx-card-gradient-border-body {
padding: 0.9em 1em 1.1em;
}
.hfx-card-gradient-border h3 {
margin: 0 0 0.25em;
font-size: 1.05em;
}
.hfx-card-gradient-border p {
margin: 0;
font-size: 0.85em;
color: #6b7280;
line-height: 1.4;
}
@keyframes hfx-card-gradient-border-spin {
to { --hfx-angle: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
.hfx-card-gradient-border, .hfx-card-gradient-border *, .hfx-card-gradient-border::before, .hfx-card-gradient-border::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--hfx-color on the element or a parent.
Currently previewing #3b82f6.--hfx-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.