Copied!
Guide

Animated SVG background patterns

A moving pattern behind a section can be a single small SVG tile. Slide the pattern by exactly one tile and the loop is seamless. Here is how, with stripes, dots and waves to copy.

← Blog
Title card: Animated SVG patterns. Preview of the Barber pole pattern element from the Enrichr Library.

December 4, 2026

3 min readOne tile, endless loop

To make an animated background pattern in SVG, define one small tile inside a <pattern> element, fill a rectangle with it, and slide the pattern by exactly one tile on a loop. Since the tile repeats, the end of the loop looks the same as the start, and the motion never seems to restart. The file stays tiny and sharp at any size.

Try it on any site. The free animation library checker shows you which animation libraries actually run on a page (GSAP, Lenis, Framer Motion). Paste a URL, no sign-up for your first lookup.

What is the code for moving stripes?

<svg class="bg" width="100%" height="100%" aria-hidden="true">
  <defs>
    <pattern id="stripes" width="40" height="40"
             patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
      <rect width="20" height="40" fill="#c6f432" />
      <animateTransform attributeName="patternTransform" type="translate"
                        from="0 0" to="40 0" dur="1.5s"
                        repeatCount="indefinite" additive="sum" />
    </pattern>
  </defs>
  <rect width="100%" height="100%" fill="#0b3d2e" />
  <rect width="100%" height="100%" fill="url(#stripes)" />
</svg>
.section { position: relative; isolation: isolate; }
.section .bg { position: absolute; inset: 0; z-index: -1; }
if (matchMedia("(prefers-reduced-motion: reduce)").matches) {
  document.querySelectorAll("svg.bg").forEach((svg) => svg.pauseAnimations());
}

How does it work?

Change dur for speed and swap from and to to reverse the direction.

How do I make dots, zigzags or waves?

PatternWhat goes in the tile
DotsOne <circle> in the centre of a square tile.
ChecksTwo squares in opposite corners.
ZigzagA <polyline> that goes up and down once across the tile.
WavesA <path> with one full curve that starts and ends at the same height.
TrianglesTwo <polygon> shapes that split the tile on the diagonal.

The rule for all of them: whatever leaves one edge of the tile must enter at the same point on the opposite edge.

Why SVG and not a video or GIF?

Which finished patterns can I copy?

ElementWhat it does
Barber pole patternDiagonal stripes in an SVG pattern that slide along their angle.
Dot wave patternA grid of small dots that sway in a slow travelling wave while bands of colour drift across.
Layered wave generatorStacked SVG waves rolling sideways along the bottom of a panel.
Triangle tile driftTwo-tone triangle tiles that slide slowly on the diagonal while their colours drift.
Zigzag stripe flowBold zigzag stripes that drift straight down in a seamless loop.
Zigzag section dividerTwo bands joined by a wide zigzag edge drawn with one stretched SVG path.

All are free in the Enrichr Library, with live controls for colour, speed and size, and the code to copy.

Where to go next

FAQ

How do I animate an SVG pattern?

Animate the patternTransform attribute with a translate equal to one tile, either with an SVG <animateTransform> element or from JavaScript. Because the pattern repeats, a shift of one tile looks identical to no shift.

Can I do the same with a CSS background?

Yes for simple shapes: a repeating-linear-gradient moved by background-position. It repaints on every frame, though. An SVG pattern, or a pattern layer moved with transform, is lighter.

Are animated SVG backgrounds bad for performance?

A simple pattern is light. Costs rise with the number of shapes per tile and the size of the area. Pause the animation when the section is off screen.

How do I pause an SVG animation for reduced motion?

Call svg.pauseAnimations() when prefers-reduced-motion: reduce matches, or do not add the animation element in that case.