Logo reveal on scroll

A logo that draws itself in is the most-requested scroll effect there is, and it is almost always built with GSAP DrawSVG for what amounts to one animated stroke-dashoffset. This example does it with a single component and no plugin registration. The interesting part is not the draw — it is what happens at 100%: onComplete fires, the outline floods with brand colour, and a second animation runs off the back of it.

014 steps

Build it, step by step

  1. Step 01 · LogoReveal.tsx

    Split the logo into outline and colour

    A path draws by its stroke, so the logo needs two layers: the outline as stroked paths with no fill, and the colour as separate shapes, hidden for now. Most exported logos are filled shapes with no stroke at all, and those have nothing to draw.

    LogoReveal.tsx11 lines
    <svg viewBox="0 0 200 200">
      {/* the colour: hidden until the outline is done */}
      <path className="logo-fill logo-disc" d={ring(70)} />
      <path className="logo-fill logo-bean-fill" d={BEAN} />
    
      {/* the outline: drawn, in this order */}
      <path className="logo-line logo-outer" d={ring(86)} />
      <path className="logo-line logo-inner" d={ring(70)} />
      <path className="logo-line logo-bean" d={BEAN} />
      <path className="logo-line logo-crease" d={CREASE} />
    </svg>
    Fig. 1.1Two layers

    .logo-line — stroked, drawn

    .logo-fill — filled, hidden

  2. Step 02 · LogoReveal.tsx

    Draw only the outline

    Wrap the SVG in <ScrollDraw> and point selector at the outline. The colour shapes are left exactly as they are. Without it the library would take every path, colour included, and try to draw shapes that have no stroke.

    LogoReveal.tsx3 lines
    <ScrollDraw selector=".logo-line">
      <svg viewBox="0 0 200 200">…</svg>
    </ScrollDraw>
    Fig. 1.2The selector
    • drawn — matches .logo-line
    • left alone — .logo-fill
  3. Step 03 · LogoReveal.tsx

    Set when it draws, and in what order

    trigger ties the drawing to the scroll: it starts when the logo’s top passes 85% of the way down the viewport and reaches the end at 35%. stagger starts each stroke a little after the one before, in the order the paths appear. Each is shifted by its share of the range, so the last stroke finishes after end: here, when the top reaches about 17%.

    LogoReveal.tsx6 lines
    <ScrollDraw
      selector=".logo-line"
      trigger={{ start: 'top 85%', end: 'top 35%' }}
      easing="ease-out"
      stagger={0.12}
    >
    Fig. 1.3When each stroke draws
    startend+0.361234

    1 outer ring · 2 inner ring · 3 bean · 4 crease — the order of the paths

  4. Step 04 · LogoReveal.tsx · logo-reveal.css

    Flood the colour at 100%

    onComplete fires when the last stroke is drawn. Flip a class there and let CSS fade the colour in. once holds the drawing once it is finished, so scrolling back up does not un-draw an outline that is already coloured.

    LogoReveal.tsx12 lines
    const [inked, setInked] = useState(false);
    
    <ScrollDraw
      className={inked ? 'logo is-inked' : 'logo'}
      once
      onComplete={() => setInked(true)}
      …
    >
    
    /* logo-reveal.css */
    .logo-fill { opacity: 0; transition: opacity 0.7s ease; }
    .is-inked .logo-fill { opacity: 1; }

    Reduced motion needs nothing extra: the library shows the finished outline at once and calls onComplete straight away, so the colour still arrives.

    Fig. 1.4The hand-off

    drawing — keep scrolling

02The whole file

The complete component

Two files, ready to paste into a React or Next.js project with svg-scroll-draw installed. The plate beside them is this exact component, running.

LogoReveal.tsx40 lines
'use client';

import { useState } from 'react';
import { ScrollDraw } from 'svg-scroll-draw/react';
import './logo-reveal.css';

/** A circle of radius r around (100, 100), as two arcs so it has a start point to draw from. */
const ring = (r: number) =>
  `M 100 ${100 - r} A ${r} ${r} 0 1 1 100 ${100 + r} A ${r} ${r} 0 1 1 100 ${100 - r}`;

const BEAN = 'M 100 58 C 124 58 132 84 130 104 C 128 126 114 142 100 142 C 76 142 68 116 70 96 C 72 74 86 58 100 58 Z';
const CREASE = 'M 101 60 C 86 84 116 114 99 140';

export function LogoReveal() {
  const [inked, setInked] = useState(false);

  return (
    <ScrollDraw
      className={inked ? 'logo is-inked' : 'logo'}
      selector=".logo-line"
      trigger={{ start: 'top 85%', end: 'top 35%' }}
      easing="ease-out"
      stagger={0.12}
      once
      onComplete={() => setInked(true)}
    >
      <svg viewBox="0 0 200 200" role="img" aria-label="Ferrow Coffee Roasters">
        {/* The colour: in place from the start, hidden until the outline is done. */}
        <path className="logo-fill logo-disc" d={ring(70)} />
        <path className="logo-fill logo-bean-fill" d={BEAN} />

        {/* The outline: what the library draws, in this order. */}
        <path className="logo-line logo-outer" d={ring(86)} />
        <path className="logo-line logo-inner" d={ring(70)} />
        <path className="logo-line logo-bean" d={BEAN} />
        <path className="logo-line logo-crease" d={CREASE} />
      </svg>
    </ScrollDraw>
  );
}
logo-reveal.css29 lines
.logo {
  --ink: #2a1b12;
  --paper: #f4ede3;
  --accent: #c4572b;
  max-width: 240px;
  margin: 0 auto;
}
.logo svg { display: block; width: 100%; height: auto; overflow: visible; }

/* The outline: stroked and never filled — a stroke is what gets drawn. */
.logo-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.5s ease;
}
.logo-inner { stroke-width: 1; }

/* The colour: present from the start, invisible until the outline finishes. */
.logo-fill { stroke: none; opacity: 0; transition: opacity 0.7s ease; }
.logo-disc { fill: var(--ink); }
.logo-bean-fill { fill: var(--accent); transition-delay: 0.15s; }

.is-inked .logo-fill { opacity: 1; }
.is-inked .logo-inner,
.is-inked .logo-crease { stroke: var(--paper); }
.is-inked .logo-bean { stroke: var(--accent); }
Fig. 2.1this file, running — scroll

No build step

The same logo as one HTML file, with the library from a CDN. Save it and open it in a browser.

index.html75 lines
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Logo reveal on scroll</title>
  <style>
    body { margin: 0; background: #f4ede3; }
    .spacer { height: 100vh; }

    .logo {
      --ink: #2a1b12;
      --paper: #f4ede3;
      --accent: #c4572b;
      max-width: 240px;
      margin: 0 auto;
    }
    .logo svg { display: block; width: 100%; height: auto; overflow: visible; }

    /* The outline: stroked and never filled — a stroke is what gets drawn. */
    .logo-line {
      fill: none;
      stroke: var(--ink);
      stroke-width: 2.4;
      stroke-linecap: round;
      stroke-linejoin: round;
      transition: stroke 0.5s ease;
    }
    .logo-inner { stroke-width: 1; }

    /* The colour: present from the start, invisible until the outline finishes. */
    .logo-fill { stroke: none; opacity: 0; transition: opacity 0.7s ease; }
    .logo-disc { fill: var(--ink); }
    .logo-bean-fill { fill: var(--accent); transition-delay: 0.15s; }

    .is-inked .logo-fill { opacity: 1; }
    .is-inked .logo-inner,
    .is-inked .logo-crease { stroke: var(--paper); }
    .is-inked .logo-bean { stroke: var(--accent); }
  </style>
</head>
<body>
  <div class="spacer"></div>

  <div class="logo" id="logo">
    <svg viewBox="0 0 200 200" role="img" aria-label="Ferrow Coffee Roasters">
      <!-- The colour: in place from the start, hidden until the outline is done. -->
      <path class="logo-fill logo-disc" d="M 100 30 A 70 70 0 1 1 100 170 A 70 70 0 1 1 100 30" />
      <path class="logo-fill logo-bean-fill" d="M 100 58 C 124 58 132 84 130 104 C 128 126 114 142 100 142 C 76 142 68 116 70 96 C 72 74 86 58 100 58 Z" />

      <!-- The outline: what the library draws, in this order. -->
      <path class="logo-line logo-outer" d="M 100 14 A 86 86 0 1 1 100 186 A 86 86 0 1 1 100 14" />
      <path class="logo-line logo-inner" d="M 100 30 A 70 70 0 1 1 100 170 A 70 70 0 1 1 100 30" />
      <path class="logo-line logo-bean" d="M 100 58 C 124 58 132 84 130 104 C 128 126 114 142 100 142 C 76 142 68 116 70 96 C 72 74 86 58 100 58 Z" />
      <path class="logo-line logo-crease" d="M 101 60 C 86 84 116 114 99 140" />
    </svg>
  </div>

  <div class="spacer"></div>

  <script src="https://unpkg.com/svg-scroll-draw@2.31.0/dist/cdn/svg-scroll-draw.global.js"></script>
  <script>
    const logo = document.getElementById('logo');

    SvgScrollDraw.scrollDraw(logo, {
      selector: '.logo-line',
      trigger: { start: 'top 85%', end: 'top 35%' },
      easing: 'ease-out',
      stagger: 0.12,
      once: true,
      onComplete: () => logo.classList.add('is-inked'),
    });
  </script>
</body>
</html>
035 problems

Where it goes wrong

01

Nothing draws

The paths are filled, not stroked, and only a stroke can be drawn. Give the outline paths fill: none and a stroke colour. The development build says so in the console: “Element has no stroke — path will not be visible.”

02

The colour is there from the start

Either the colour shapes are visible, or selector matches them too. Keep them out of the selector and at opacity: 0 until onComplete.

03

Scrolling back up un-draws the outline under the colour

Without once, the outline follows the scroll both ways, but onComplete has no opposite, so the class stays on. Keep once. If the logo should rewind instead, drop once and take the class off in onEnterBack, which fires when the reader scrolls back into the range.

04

It is already drawn when the page loads

A logo near the top of the page can be past top 35% before anyone scrolls, so it loads drawn. For a hero logo, draw it on load instead with autoplay and a duration, as the live Ferrow site does.

05

The strokes draw in the wrong order

stagger follows the order of the paths in the SVG. Reorder the <path> elements, not the CSS.

01autoplay · onComplete · fill

In a real site

A full launch site for a fictional Lisbon roaster. The emblem draws itself as the page loads and onComplete floods it with the brand colours; further down, origin drawings, farm-to-roastery routes, a roast profile and the head roaster's signature draw as you scroll.

Ferrow Coffee Roasters, a small-lot coffee roaster in lisbon: the first screen of its demo site

A small-lot coffee roaster in Lisbon

Ferrow Coffee Roasters

Live site

Related examples

Make your own in the SVG line drawing generator or the SVG path viewer: set it up, watch it run, copy the code.

MIT licensed, zero runtime dependencies. Every API is a separate entry point, so you only ship what you import. Full API reference →