AI CSS Animations

Firework Burst Loader

A flash at the center, twelve sparks streak out in alternating hues and fizzle, and a smaller shell follows half a beat later. Fast out, slow fade. Fits celebratory waits like publishing.

Also known as: fireworks animation css, burst loader, explosion animation.

HTML

<div class="ldr-firework" role="status" aria-label="Loading">
  <span style="--i: 0"></span><span style="--i: 1"></span><span style="--i: 2"></span><span style="--i: 3"></span>
  <span style="--i: 4"></span><span style="--i: 5"></span><span style="--i: 6"></span><span style="--i: 7"></span>
  <span style="--i: 8"></span><span style="--i: 9"></span><span style="--i: 10"></span><span style="--i: 11"></span>
</div>

CSS

.ldr-firework {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: var(--s);
  height: var(--s);
  filter: drop-shadow(0 0 calc(var(--s) / 20) color-mix(in srgb, var(--ldr-color, #3b82f6) 70%, transparent));
}
.ldr-firework::before {
  content: "";
  position: absolute;
  inset: 34%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--c) 40%, #fff), var(--c) 45%, transparent);
  animation: ldr-firework-flash 1.8s ease-out infinite;
}
.ldr-firework span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(var(--s) * 0.06);
  height: calc(var(--s) * 0.2);
  margin: calc(var(--s) * -0.2) 0 0 calc(var(--s) * -0.03);
  transform-origin: 50% 100%;
  transform: rotate(calc(var(--i) * 30deg));
}
.ldr-firework span::before,
.ldr-firework span::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: calc(var(--s) * 0.03);
  background: linear-gradient(var(--k, var(--c)), transparent);
  opacity: 0;
  animation: ldr-firework-burst 1.8s cubic-bezier(0.1, 0.75, 0.3, 1) infinite;
}
.ldr-firework span::after {
  --k: oklch(from var(--c) l c calc(h - 60));
  transform-origin: 50% 100%;
  rotate: 15deg;
  scale: 0.7;
  animation-delay: -0.9s;
}
.ldr-firework span:nth-child(odd) {
  --k: oklch(from var(--c) l c calc(h + 70));
}
@keyframes ldr-firework-flash {
  0%        { transform: scale(0.2); opacity: 1; }
  25%, 100% { transform: scale(1.4); opacity: 0; }
}
@keyframes ldr-firework-burst {
  0%   { transform: translateY(0) scaleY(0.2); opacity: 0; }
  6%   { opacity: 1; }
  50%  { transform: translateY(calc(var(--s) * -0.24)) scaleY(1); opacity: 1; }
  100% { transform: translateY(calc(var(--s) * -0.3)) scaleY(0.1); opacity: 0; }
}

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