Back to Explore
THE PLAYGROUND · CORE MOTION

Path Animation

A line draws itself along a curved path.

Path AnimationCore Motion · A line draws itself along a curved path.
CLICK
CLICK TO REPLAY · 600 ms
1import { useState } from "react";2import { motion } from "motion/react";3 4const surface = { width: 100, height: 100, borderRadius: 16, background: "#b8ed79", display: "grid", placeItems: "center", color: "#141714" };5 6export default function PathDemo() {7  const [run, setRun] = useState(0);8  return <div><button onClick={() => setRun(v => v+1)}>Replay</button>9    <svg viewBox="0 0 240 120" width="320"><motion.path key={run} d="M20 95 C55 95 40 20 90 25 S145 115 180 55 S210 25 225 25" fill="none" stroke="#b8ed79" strokeWidth="3" initial={{pathLength:0}} animate={{pathLength:1}} transition={{ duration: 0.6, delay: 0, ease: "easeInOut" }} /></svg>10  </div>;11}

Install: npm install motion. Animate SVG path length from zero to one. This compact example illustrates the core technique; the styled playground contains additional presentation details.