AI CSS Animations

Heartbeat Loader

A CSS-drawn heart that beats with a double thump. Built from two rotated pseudo-elements, no SVG or icon font required.

HTML

<div class="ldr-heart" role="status" aria-label="Loading"></div>

CSS

.ldr-heart {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: var(--s);
  height: calc(var(--s) * 0.9);
  animation: ldr-heart-beat 1.2s ease-in-out infinite;
}
.ldr-heart::before,
.ldr-heart::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 80%;
  background: var(--c);
  border-radius: calc(var(--s) / 2) calc(var(--s) / 2) 0 0;
  transform: rotate(-45deg);
  transform-origin: 0 100%;
}
.ldr-heart::after {
  left: 0;
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}
@keyframes ldr-heart-beat {
  0%, 100% { transform: scale(1); }
  14%      { transform: scale(1.12); }
  28%      { transform: scale(1); }
  42%      { transform: scale(1.12); }
  70%      { transform: scale(1); }
}

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