AI CSS Animations

DNA Helix Loader

Two strands of dots weave past each other, shrinking as they pass behind and growing as they come to the front. Eight columns, two pseudo-elements each, no SVG.

Also known as: double helix animation, DNA strand loader.

HTML

<div class="ldr-dna-helix" role="status" aria-label="Loading">
  <span></span><span></span><span></span><span></span>
  <span></span><span></span><span></span><span></span>
</div>

CSS

.ldr-dna-helix {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  display: flex;
  gap: calc(var(--s) / 10);
  height: var(--s);
}
.ldr-dna-helix span {
  position: relative;
  width: calc(var(--s) / 10);
  height: 100%;
}
.ldr-dna-helix span::before,
.ldr-dna-helix span::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--c);
  animation: ldr-dna-helix-weave 1.6s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
.ldr-dna-helix span::after {
  background: color-mix(in srgb, var(--ldr-color, #3b82f6) 50%, transparent);
  animation-delay: calc(var(--d, 0s) - 0.8s);
}
.ldr-dna-helix span:nth-child(2) { --d: -0.15s; }
.ldr-dna-helix span:nth-child(3) { --d: -0.3s; }
.ldr-dna-helix span:nth-child(4) { --d: -0.45s; }
.ldr-dna-helix span:nth-child(5) { --d: -0.6s; }
.ldr-dna-helix span:nth-child(6) { --d: -0.75s; }
.ldr-dna-helix span:nth-child(7) { --d: -0.9s; }
.ldr-dna-helix span:nth-child(8) { --d: -1.05s; }
@keyframes ldr-dna-helix-weave {
  0%, 100% { transform: translateY(0) scale(1); }
  25%      { transform: translateY(calc(var(--s) * 0.45)) scale(0.55); }
  50%      { transform: translateY(calc(var(--s) * 0.9)) scale(1); }
  75%      { transform: translateY(calc(var(--s) * 0.45)) scale(1.25); }
}

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