AI CSS Animations

Pulsing Glow Border

The border and its glow beat twice, then rest, like a heartbeat monitor. Good for live, recording or needs-attention states. A shadow ring on a pseudo-element scales and fades on a lub-dub keyframe.

Also known as: pulsating glow effect css, heartbeat glow border, glow pulse animation.

Recording

HTML

<div class="bdr-pulsing-glow-border"><span class="bdr-pulsing-glow-border-dot"></span>Recording</div>

CSS

.bdr-pulsing-glow-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;
  --beat: 1.4s cubic-bezier(0.33, 0, 0.2, 1) infinite;
  grid-auto-flow: column;
  gap: 0.5em;
  justify-content: center;
  border: 0.12em solid var(--c);
  box-sizing: border-box;
  background: color-mix(in srgb, var(--c) 6%, transparent);
}
.bdr-pulsing-glow-border::before {
  content: "";
  position: absolute;
  inset: -0.12em;
  border-radius: inherit;
  box-shadow: 0 0 0.3em 0.1em var(--c), 0 0 1.4em color-mix(in srgb, var(--c) 60%, transparent), inset 0 0 0.9em color-mix(in srgb, var(--c) 35%, transparent);
  pointer-events: none;
  animation: bdr-pulsing-glow-border-beat var(--beat);
}
.bdr-pulsing-glow-border-dot {
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0.5em var(--c);
  animation: bdr-pulsing-glow-border-beat var(--beat);
}
@keyframes bdr-pulsing-glow-border-beat {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  10%      { opacity: 1; transform: scale(1.025); }
  20%      { opacity: 0.45; transform: scale(1); }
  32%      { opacity: 0.95; transform: scale(1.02); }
  60%      { opacity: 0.25; transform: scale(1); }
}

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

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