AI CSS Animations

Spotlight Sweep Loader

A lamp swings its cone of light from side to side while the lit spot slides along the floor below. Fits search, lookup and discovery states. The beam is a soft conic wedge, not a blurred shape.

Also known as: searchlight animation, light beam loader, stage light css.

HTML

<div class="ldr-spotlight" role="status" aria-label="Searching">
  <span class="ldr-spotlight-beam"></span>
  <span class="ldr-spotlight-spot"></span>
</div>

CSS

.ldr-spotlight {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: calc(var(--s) * 1.8);
  height: calc(var(--s) * 1.1);
}
.ldr-spotlight-beam {
  position: absolute;
  top: 0;
  left: 50%;
  width: calc(var(--s) * 1.2);
  height: calc(var(--s) * 1);
  margin-left: calc(var(--s) * -0.6);
  background: conic-gradient(from 162deg at 50% calc(var(--s) * 0.06), transparent, color-mix(in srgb, var(--ldr-color, #3b82f6) 50%, transparent) 12deg, color-mix(in srgb, var(--ldr-color, #3b82f6) 65%, transparent) 18deg, color-mix(in srgb, var(--ldr-color, #3b82f6) 50%, transparent) 24deg, transparent 36deg);
  -webkit-mask: linear-gradient(#000 25%, rgba(0, 0, 0, 0.25));
  mask: linear-gradient(#000 25%, rgba(0, 0, 0, 0.25));
  transform-origin: 50% calc(var(--s) * 0.06);
  animation: ldr-spotlight-sweep 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
.ldr-spotlight-beam::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: calc(var(--s) * 0.24);
  height: calc(var(--s) * 0.14);
  margin-left: calc(var(--s) * -0.12);
  border-radius: calc(var(--s) * 0.04) calc(var(--s) * 0.04) calc(var(--s) * 0.12) calc(var(--s) * 0.12);
  background: var(--c);
}
.ldr-spotlight-spot {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: calc(var(--s) * 0.6);
  height: calc(var(--s) * 0.16);
  margin-left: calc(var(--s) * -0.3);
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--ldr-color, #3b82f6) 75%, transparent), color-mix(in srgb, var(--ldr-color, #3b82f6) 30%, transparent) 60%, transparent);
  animation: ldr-spotlight-slide 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
@keyframes ldr-spotlight-sweep {
  from { transform: rotate(28deg); }
  to   { transform: rotate(-28deg); }
}
@keyframes ldr-spotlight-slide {
  from { transform: translateX(calc(var(--s) * -0.52)); }
  to   { transform: translateX(calc(var(--s) * 0.52)); }
}

@media (prefers-reduced-motion: reduce) {
  .ldr-spotlight, .ldr-spotlight *, .ldr-spotlight::before, .ldr-spotlight::after, .ldr-spotlight *::before, .ldr-spotlight *::after {
    animation-duration: 3s;
  }
}

Customizing this loader

  • Color: set --ldr-color on the element or a parent. Currently previewing #3b82f6.
  • Size: set --ldr-size. Every dimension in the snippet is derived from it. Currently previewing 64px.
  • Speed: change the duration on the animation shorthand. Delays on the children are relative, so they keep their rhythm.
  • Accessibility: the root carries role="status" and an aria-label so screen readers announce the wait. The reduced-motion rule at the end slows the animation for users who asked for less motion.

Similar loaders