AI CSS Animations

Bar Chart Loader

Four chart bars spring up from an axis with a little overshoot, hold, then drop away and grow again. A natural fit for dashboards, reports and analytics panels while data loads.

Also known as: chart loading animation, graph loader, analytics loader.

HTML

<div class="ldr-bar-chart" role="status" aria-label="Loading chart">
  <span></span><span></span><span></span><span></span>
</div>

CSS

.ldr-bar-chart {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: calc(var(--s) / 9);
  box-sizing: border-box;
  width: calc(var(--s) * 1.2);
  height: var(--s);
  padding: 0 calc(var(--s) / 10) calc(var(--s) / 12);
}
.ldr-bar-chart::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--s) / 20);
  border-radius: var(--s);
  background: color-mix(in srgb, var(--ldr-color, #3b82f6) 35%, transparent);
}
.ldr-bar-chart span {
  flex: 1;
  height: var(--h);
  border-radius: calc(var(--s) / 20) calc(var(--s) / 20) 0 0;
  background: color-mix(in srgb, var(--ldr-color, #3b82f6) 50%, transparent);
  transform: scaleY(0);
  transform-origin: 50% 100%;
  animation: ldr-bar-chart-grow 2.4s infinite;
}
.ldr-bar-chart span:nth-child(1) { --h: 42%; }
.ldr-bar-chart span:nth-child(2) { --h: 68%; animation-delay: 0.15s; }
.ldr-bar-chart span:nth-child(3) { --h: 54%; animation-delay: 0.3s; }
.ldr-bar-chart span:nth-child(4) { --h: 92%; animation-delay: 0.45s; background: var(--c); }
@keyframes ldr-bar-chart-grow {
  0%       { transform: scaleY(0); animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
  22%      { transform: scaleY(1); }
  68%      { transform: scaleY(1); animation-timing-function: cubic-bezier(0.5, 0, 0.75, 0); }
  80%, 100% { transform: scaleY(0); }
}

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