2.13 · Animation

SVG Path Drawing.

Lines, signatures, logos and underlines that draw themselves on scroll using the stroke-dasharray trick. Pure CSS — no library needed.

What it is

An SVG path animates from invisible to fully drawn, as if a hand is sketching it in real time. The technique works on anything you can draw as an SVG path: a signature, a logo outline, decorative underlines, mountain ranges, line charts, illustrated icons. The reveal feels organic and editorial — perfect for portfolio sites, brand pages, and case studies.

How it works

The trick uses two CSS properties: stroke-dasharray defines a long dash equal to the path's total length, and stroke-dashoffset shifts that dash off the visible area. So initially, the entire path is "in the gap" and invisible. Transitioning stroke-dashoffset back to 0 walks the dash into the visible area, drawing the path. You need the path's getTotalLength() JS value (or just use a number larger than any reasonable path, like 2000, and round). IntersectionObserver fires the draw on scroll.

stroke-dasharray: LOne dash of length L (= path length), with no gap pattern
stroke-dashoffset: L → 0Shifts the dash from off-screen to drawn — animate this
path.getTotalLength()JS method that returns the exact path length in user units
stroke-linecap: roundRounds the endpoints so lines don't end on a square stub

Live demo

Scroll inside. Each path draws itself when it enters view.

Live · scroll inside
↓ scroll to draw
01 / Underline

Quiet by design, fast by default.

Hand-drawn underline used as a custom emphasis under a key phrase.

02 / Signature

Sincerely yours,

Drawing-style signature commonly used at the bottom of editorial pieces and brand homepages.

03 / Chart

Six months of growth.

Line charts that draw left-to-right on scroll are an excellent way to make data feel narrative.

04 / Logo mark

The studio mark.

A geometric logo outline drawn as a single sequence. Often used for splash screens and logo reveals.

— end —

Copy this prompt

Prompt · 2.13 SVG Path Draw
Build an SVG path-drawing animation triggered on scroll. For each SVG path you want to animate, give it class="draw" with these CSS properties: fill:none, stroke:accent-color, stroke-width:2.5, stroke-linecap:round, stroke-dasharray:var(--len), stroke-dashoffset:var(--len). Initial state: the entire path is "in the gap" so invisible. On JS load, for each .draw path, call path.getTotalLength() and set its --len custom property to that value (so dasharray and dashoffset match the path exactly). Use IntersectionObserver on each parent container — when the container enters view (threshold 0.3), add an .in class that transitions stroke-dashoffset to 0 over 2.2 seconds with cubic-bezier(0.65, 0, 0.35, 1). Demonstrate four variations: (1) a wavy underline under a key phrase, (2) a script "signature" with looping curves, (3) a line-chart polyline that draws left-to-right, (4) a geometric logo combining a diamond path + an inscribed circle. Unobserve after first trigger.

Example sites to study