AI CSS Animations

Glowing Gradient Border

A rotating gradient border with a soft bloom of the same colors spilling out behind it. The glow is a blurred copy of the conic layer, so the light turns with the border instead of sitting still.

Also known as: animated glowing gradient border css, gradient border with glow, rotating glow border.

Glowing gradient

HTML

<div class="bdr-glowing-gradient-border">Glowing gradient</div>

CSS

@property --bdr-glowing-gradient-border-a {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.bdr-glowing-gradient-border {
  --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;
  --fill: color-mix(in srgb, var(--c) 10%, #0b0f19);
  --ring: conic-gradient(from var(--bdr-glowing-gradient-border-a), var(--c), color-mix(in oklch, var(--c), #d946ef 70%), color-mix(in oklch, var(--c), #22d3ee 70%), var(--c));
  isolation: isolate;
  color: #f1f5f9;
  animation: bdr-glowing-gradient-border-spin 4s linear infinite;
}
.bdr-glowing-gradient-border::before,
.bdr-glowing-gradient-border::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
}
.bdr-glowing-gradient-border::before {
  inset: 0.3em;
  background: var(--ring);
  filter: blur(0.9em);
  opacity: 0.75;
}
.bdr-glowing-gradient-border::after {
  inset: 0;
  border: 0.16em solid transparent;
  background: linear-gradient(var(--fill), var(--fill)) padding-box, var(--ring) border-box;
}
@keyframes bdr-glowing-gradient-border-spin {
  to { --bdr-glowing-gradient-border-a: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
  .bdr-glowing-gradient-border, .bdr-glowing-gradient-border *, .bdr-glowing-gradient-border::before, .bdr-glowing-gradient-border::after, .bdr-glowing-gradient-border *::before, .bdr-glowing-gradient-border *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Tailwind CSS version

The same effect using Tailwind utility classes. No custom CSS or config needed.

<div class="relative isolate grid h-[8.5em] w-[15em] place-items-center font-semibold text-slate-100">
  <div class="absolute inset-1 -z-10 overflow-hidden rounded-2xl opacity-75 blur-xl">
    <div class="absolute inset-[-100%] animate-spin bg-[conic-gradient(#3b82f6,#d946ef,#22d3ee,#3b82f6)] [animation-duration:4s]"></div>
  </div>
  <div class="absolute inset-0 -z-10 overflow-hidden rounded-2xl p-[2px]">
    <div class="absolute inset-[-100%] animate-spin bg-[conic-gradient(#3b82f6,#d946ef,#22d3ee,#3b82f6)] [animation-duration:4s]"></div>
    <div class="relative h-full w-full rounded-[14px] bg-slate-950"></div>
  </div>
  Glowing gradient
</div>

Customizing this snippet

  • Color: set --bdr-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --bdr-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar border animations