AI CSS Animations

Edge Glow Background

A band of shifting color glows along all four edges of a dark frame, flowing around it like an AI assistant listening. A spinning conic gradient seen through a static edge mask.

Also known as: screen edge glow css, ai assistant glow effect, glowing frame background.

HTML

<div class="bgx-edge-glow" aria-hidden="true"><span></span><span></span></div>

CSS

.bgx-edge-glow {
  --c: var(--bgx-color, #3b82f6);
  font-size: var(--bgx-size, 16px);
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #050508;
}
.bgx-edge-glow span {
  position: absolute;
  inset: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, #000, transparent var(--f) calc(100% - var(--f)), #000), linear-gradient(#000, transparent var(--f) calc(100% - var(--f)), #000);
  mask-image: linear-gradient(to right, #000, transparent var(--f) calc(100% - var(--f)), #000), linear-gradient(#000, transparent var(--f) calc(100% - var(--f)), #000);
}
.bgx-edge-glow span:nth-child(1) { --f: 4em; opacity: 0.7; }
.bgx-edge-glow span:nth-child(2) { --f: 0.6em; }
.bgx-edge-glow span::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 250%;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: conic-gradient(var(--c), oklch(from var(--c) 0.68 0.24 calc(h + 70)), oklch(from var(--c) 0.82 0.16 calc(h + 150)), oklch(from var(--c) 0.72 0.18 calc(h - 60)), var(--c));
  animation: bgx-edge-glow-spin 5s linear infinite;
}
@keyframes bgx-edge-glow-spin {
  to { transform: rotate(1turn); }
}

@media (prefers-reduced-motion: reduce) {
  .bgx-edge-glow, .bgx-edge-glow *, .bgx-edge-glow::before, .bgx-edge-glow::after, .bgx-edge-glow *::before, .bgx-edge-glow *::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="absolute inset-0 overflow-hidden bg-[#050508]" aria-hidden="true">
  <div class="absolute inset-0 overflow-hidden opacity-70 [mask-image:linear-gradient(to_right,#000,transparent_3rem_calc(100%_-_3rem),#000),linear-gradient(#000,transparent_3rem_calc(100%_-_3rem),#000)]">
    <div class="absolute left-1/2 top-1/2 aspect-square w-[250%] -translate-x-1/2 -translate-y-1/2">
      <div class="h-full w-full animate-spin bg-[conic-gradient(#3b82f6,#d946ef,#fb923c,#22d3ee,#3b82f6)] [animation-duration:5s]"></div>
    </div>
  </div>
  <div class="absolute inset-0 overflow-hidden [mask-image:linear-gradient(to_right,#000,transparent_0.5rem_calc(100%_-_0.5rem),#000),linear-gradient(#000,transparent_0.5rem_calc(100%_-_0.5rem),#000)]">
    <div class="absolute left-1/2 top-1/2 aspect-square w-[250%] -translate-x-1/2 -translate-y-1/2">
      <div class="h-full w-full animate-spin bg-[conic-gradient(#3b82f6,#d946ef,#fb923c,#22d3ee,#3b82f6)] [animation-duration:5s]"></div>
    </div>
  </div>
</div>

Customizing this snippet

  • Color: set --bgx-color on the element or a parent. Currently previewing #3b82f6.
  • Pattern scale: set --bgx-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 animated backgrounds