SVG Stroke Reveal.
Draw an SVG path by animating its stroke dash offset with CSS.
View code
<svg class="route" viewBox="0 0 280 150" aria-label="Animated path" role="img"><path class="draw" d="M20 102 C60 9 99 11 133 69 S215 140 260 50" pathLength="1" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round"/></svg>:root { color-scheme: dark; font: 15px system-ui, sans-serif; color: #dbff55; }
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: grid; place-items: center; overflow: hidden; background: transparent; }
.tile { display: grid; place-items: center; width: 68px; aspect-ratio: 1; border-radius: 18px; background: currentColor; }
.tile { background: #dbff55; color: #202415; font-size: 30px; }
canvas { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; }
button { font: inherit; color: #f3f1e9; background: #191919; border: 1px solid #ffffff66; padding: 8px 14px; border-radius: 24px; cursor: pointer; }
:focus-visible { outline: 2px solid #dbff55; outline-offset: -3px; }
.notice { max-width: 34ch; padding: 16px; color: #fff; }
@media (prefers-reduced-motion: reduce) { .sprite { animation-play-state: paused; } }
.route { width:min(86%,420px); height:80%; }
.draw { stroke-dasharray:1; animation: trace 2.4s ease-in-out infinite alternate; }
@keyframes trace { from { stroke-dashoffset:1; } to { stroke-dashoffset:0; } }
@media (prefers-reduced-motion: reduce) { .draw { animation:none; } }// pathLength normalizes the full stroke to one unit.