AI CSS Animations

Marquee Lights Border

A ring of bulbs like a theater marquee, with the light chasing around in steps. Three dotted SVG strokes share the bulbs between them and take turns lighting up, so nothing moves but opacity.

Also known as: theater lights border css, chasing lights animation, led light border.

Now showing

HTML

<div class="bdr-marquee-lights-border">
  <svg class="bdr-marquee-lights-border-svg" aria-hidden="true">
    <rect class="bdr-marquee-lights-border-bulbs" width="100%" height="100%" pathLength="120"/>
    <rect class="bdr-marquee-lights-border-lit" width="100%" height="100%" pathLength="120"/>
    <rect class="bdr-marquee-lights-border-lit" width="100%" height="100%" pathLength="120"/>
    <rect class="bdr-marquee-lights-border-lit" width="100%" height="100%" pathLength="120"/>
  </svg>
  <span class="bdr-marquee-lights-border-text">Now showing</span>
</div>

CSS

.bdr-marquee-lights-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;
  background: color-mix(in srgb, var(--c) 10%, #0d0c10);
  color: color-mix(in srgb, var(--c) 30%, #fff);
}
.bdr-marquee-lights-border-svg {
  position: absolute;
  inset: 0.6em;
  width: calc(100% - 1.2em);
  height: calc(100% - 1.2em);
  overflow: visible;
  pointer-events: none;
}
.bdr-marquee-lights-border-svg rect {
  rx: 0.5em;
  fill: none;
  stroke-width: 0.42em;
  stroke-linecap: round;
}
.bdr-marquee-lights-border-bulbs {
  stroke: color-mix(in srgb, var(--c) 28%, transparent);
  stroke-dasharray: 0 4;
}
.bdr-marquee-lights-border-lit {
  stroke: color-mix(in srgb, var(--c) 35%, #fff);
  stroke-dasharray: 0 12;
  filter: drop-shadow(0 0 0.2em var(--c));
  animation: bdr-marquee-lights-border-chase 0.6s step-end infinite;
}
.bdr-marquee-lights-border-lit:nth-of-type(3) { stroke-dashoffset: -4; animation-delay: -0.4s; }
.bdr-marquee-lights-border-lit:nth-of-type(4) { stroke-dashoffset: -8; animation-delay: -0.2s; }
.bdr-marquee-lights-border-text {
  font-size: 1.05em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0 0.5em var(--c);
}
@keyframes bdr-marquee-lights-border-chase {
  0%          { opacity: 1; }
  33.3%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bdr-marquee-lights-border, .bdr-marquee-lights-border *, .bdr-marquee-lights-border::before, .bdr-marquee-lights-border::after, .bdr-marquee-lights-border *::before, .bdr-marquee-lights-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