AI CSS Animations

Neural Network Loader

Three layers of nodes wired together: each layer lights up and sends small pulses along its connections to the next. One SVG, and the pulses are just a moving stroke dash.

Also known as: ai network loading animation, machine learning loader, nodes connecting animation.

HTML

<div class="ldr-neural-network" role="status" aria-label="Processing">
  <svg viewBox="0 0 60 36" aria-hidden="true">
    <path class="ldr-neural-network-wire" d="M6 8L30 3M6 8L30 13M6 8L30 23M6 8L30 33M6 18L30 3M6 18L30 13M6 18L30 23M6 18L30 33M6 28L30 3M6 28L30 13M6 28L30 23M6 28L30 33M30 3L54 13M30 3L54 23M30 13L54 13M30 13L54 23M30 23L54 13M30 23L54 23M30 33L54 13M30 33L54 23"/>
    <path class="ldr-neural-network-pulse ldr-neural-network-p1" d="M6 8L30 3M6 8L30 13M6 8L30 23M6 8L30 33M6 18L30 3M6 18L30 13M6 18L30 23M6 18L30 33M6 28L30 3M6 28L30 13M6 28L30 23M6 28L30 33"/>
    <path class="ldr-neural-network-pulse ldr-neural-network-p2" d="M30 3L54 13M30 3L54 23M30 13L54 13M30 13L54 23M30 23L54 13M30 23L54 23M30 33L54 13M30 33L54 23"/>
    <g class="ldr-neural-network-l1"><circle cx="6" cy="8" r="3"/><circle cx="6" cy="18" r="3"/><circle cx="6" cy="28" r="3"/></g>
    <g class="ldr-neural-network-l2"><circle cx="30" cy="3" r="2.6"/><circle cx="30" cy="13" r="2.6"/><circle cx="30" cy="23" r="2.6"/><circle cx="30" cy="33" r="2.6"/></g>
    <g class="ldr-neural-network-l3"><circle cx="54" cy="13" r="3"/><circle cx="54" cy="23" r="3"/></g>
  </svg>
</div>

CSS

.ldr-neural-network {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  width: calc(var(--s) * 1.8);
  height: calc(var(--s) * 1.08);
}
.ldr-neural-network svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.ldr-neural-network-wire {
  fill: none;
  stroke: color-mix(in srgb, var(--ldr-color, #3b82f6) 22%, transparent);
  stroke-width: 0.8;
}
.ldr-neural-network-pulse {
  fill: none;
  stroke: var(--c);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 5 60;
  stroke-dashoffset: 5;
  animation: ldr-neural-network-travel 1.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.ldr-neural-network-p1 { animation-delay: 0.1s; }
.ldr-neural-network-p2 { animation-delay: 0.64s; }
.ldr-neural-network circle {
  fill: var(--c);
  opacity: 0.35;
  transform-box: fill-box;
  transform-origin: center;
  animation: ldr-neural-network-fire 1.8s ease-out infinite;
}
.ldr-neural-network-l1 circle { animation-delay: 0s; }
.ldr-neural-network-l2 circle { animation-delay: 0.5s; }
.ldr-neural-network-l3 circle { animation-delay: 1.04s; }
@keyframes ldr-neural-network-travel {
  0%        { stroke-dashoffset: 5; }
  30%, 100% { stroke-dashoffset: -36; }
}
@keyframes ldr-neural-network-fire {
  0%, 30%, 100% { opacity: 0.35; transform: scale(1); }
  8%            { opacity: 1; transform: scale(1.3); }
}

@media (prefers-reduced-motion: reduce) {
  .ldr-neural-network, .ldr-neural-network *, .ldr-neural-network::before, .ldr-neural-network::after, .ldr-neural-network *::before, .ldr-neural-network *::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