Skip to content

Draw-on-scroll Path

A stroked signature curve that traces itself when it enters view, using the path's own measured length and nothing else. Draw and Clear work by hand, and the curve's content is described in text.

220
MIT licensev1.0.02 KB gzipzero dependenciesby Motif Studioadded 2026-09-10review due 2026-12-09
Live playground — drag, click, hoversandboxed previewsample copy

Signature curve

cleared · entered view 0×

A single curve that draws itselfA stroked path that rises from the lower left, loops once and settles near the top right. It draws when it enters view and can be redrawn with the button below.
measuring the path…
  • · One stroked path, 9 curve segments, drawn at 1.6px on a 210×128 grid
  • · It traces when the frame scrolls into view, and again whenever you press Draw
  • · dashoffset does the work, so nothing re-lays out while it draws

A decoration nobody can perceive is still a decoration: the description inside the SVG carries the same content, the buttons work whether or not the path ever draws itself, and reduced motion skips the 1200ms entirely.

Ambience
vibes

Ambience is a live light wash over the preview. Full palette re-theming of every demo arrives with Theme Studio (Pro).

deps: zeroJSX + TailwindMIT · original
draw-path.tsx
// Draw-on-scroll Path — the demo's own source, extracted verbatim.
// From src/components/demos/scenes-17.tsx, export DrawOnScroll.
// Needs React 18+ and Tailwind CSS v4. The classes below include this site's
// token utilities (bg-panel, text-ink-dim, chip …); their values are served as
// CSS custom properties at /api/exports/tokens.json. The reduced-motion branch
// is part of the source, not an afterthought.
// 3 helpers the demo imports are inlined above it, verbatim.

import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";

function useReducedMotion() {
  const [reduced, setReduced] = useState<boolean>(() =>
    typeof window !== "undefined" ? window.matchMedia("(prefers-reduced-motion: reduce)").matches : false
  );
  useEffect(() => {
    const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
    const on = (e: MediaQueryListEvent) => setReduced(e.matches);
    mq.addEventListener("change", on);
    return () => mq.removeEventListener("change", on);
  }, []);
  return reduced;
}

const DRAW_PATH =
  "M14 96 C 40 20, 74 20, 86 62 S 118 128, 138 74 C 152 36, 174 30, 196 52 C 214 70, 214 96, 186 104 C 158 112, 132 96, 132 72 C 132 44, 160 20, 196 20";

const DRAW_NOTES = [
  "One stroked path, 9 curve segments, drawn at 1.6px on a 210×128 grid",
  "It traces when the frame scrolls into view, and again whenever you press Draw",
  "dashoffset does the work, so nothing re-lays out while it draws",
];

export function DrawOnScroll() {
  const uid = useId();
  const pathRef = useRef<SVGPathElement>(null);
  const boxRef = useRef<HTMLDivElement>(null);
  const [length, setLength] = useState(0);
  const [drawn, setDrawn] = useState(false);
  const [seen, setSeen] = useState(0);
  const reduced = useReducedMotion();

  useLayoutEffect(() => {
    const path = pathRef.current;
    if (!path) return;
    try {
      setLength(path.getTotalLength());
    } catch {
      setLength(0); // no SVG geometry API: the path stays drawn without the trace
    }
  }, []);

  useEffect(() => {
    const box = boxRef.current;
    if (!box || typeof IntersectionObserver === "undefined") {
      setDrawn(true); // no observer: show the finished path rather than nothing
      return;
    }
    const observer = new IntersectionObserver(
      (entries) => {
        for (const entry of entries) {
          if (entry.isIntersecting) {
            setSeen((n) => n + 1);
            setDrawn(true);
          }
        }
      },
      { threshold: 0.4 }
    );
    observer.observe(box);
    return () => observer.disconnect();
  }, []);

  return (
    <div className="flex h-full w-full flex-col items-center justify-center bg-[radial-gradient(70%_90%_at_50%_100%,rgba(56,189,248,0.12),transparent_60%),#08090f] px-6 py-6">
      <div className="w-full max-w-md">
        <div className="mb-3 flex items-baseline justify-between gap-3">
          <p className="text-[10px] font-bold uppercase tracking-[0.24em] text-sky-300/80">Signature curve</p>
          <p className="text-[10px] tabular-nums text-ink-faint">
            {drawn ? "drawn" : "cleared"} · entered view {seen}×
          </p>
        </div>

        <div ref={boxRef} className="rounded-2xl border border-white/10 bg-white/[.02] p-3">
          <svg viewBox="0 0 210 128" className="h-40 w-full" role="img" aria-labelledby={`${uid}-draw-title ${uid}-draw-desc`}>
            <title id={`${uid}-draw-title`}>A single curve that draws itself</title>
            <desc id={`${uid}-draw-desc`}>
              A stroked path that rises from the lower left, loops once and settles near the top right. It draws when it enters
              view and can be redrawn with the button below.
            </desc>
            <path d="M6 116 H204" stroke="rgba(255,255,255,.08)" strokeWidth="1" />
            <path d="M6 64 H204" stroke="rgba(255,255,255,.05)" strokeWidth="1" strokeDasharray="4 8" />
            <path d={DRAW_PATH} fill="none" stroke="rgba(255,255,255,.06)" strokeWidth="1.6" strokeLinecap="round" />
            <path
              ref={pathRef}
              d={DRAW_PATH}
              fill="none"
              stroke="#7dd3fc"
              strokeWidth="1.6"
              strokeLinecap="round"
              style={{
                strokeDasharray: length || undefined,
                strokeDashoffset: length ? length * (drawn ? 0 : 1) : undefined,
                transition: reduced ? "none" : "stroke-dashoffset 1200ms cubic-bezier(0.4, 0, 0.2, 1)",
              }}
            />
            <circle cx="14" cy="96" r="2.6" fill="#7dd3fc" opacity={drawn ? 1 : 0} />
            <circle cx="196" cy="20" r="2.6" fill="#7dd3fc" opacity={drawn ? 1 : 0} />
          </svg>

          <div className="mt-2 flex flex-wrap items-center gap-2">
            <button
              type="button"
              onClick={() => {
                setDrawn(false);
                // One frame lets the browser apply the reset before the
                // transition runs again; without it the path never redraws.
                requestAnimationFrame(() => setDrawn(true));
              }}
              className="btn btn-ghost !px-3.5 !py-2 text-[11px]"
            >
              Draw
            </button>
            <button type="button" onClick={() => setDrawn(false)} className="btn btn-ghost !px-3.5 !py-2 text-[11px]">
              Clear
            </button>
            <span className="text-[10px] text-ink-faint">
              {length ? `${Math.round(length)}px of path` : "measuring the path…"}
            </span>
          </div>
        </div>

        <ul className="mt-3 space-y-1">
          {DRAW_NOTES.map((n) => (
            <li key={n} className="text-[10px] leading-relaxed text-ink-dim">
              · {n}
            </li>
          ))}
        </ul>
        <p className="mt-2 text-[10px] leading-relaxed text-ink-faint">
          A decoration nobody can perceive is still a decoration: the description inside the SVG carries the same content, the
          buttons work whether or not the path ever draws itself, and reduced motion skips the 1200ms entirely.
        </p>
      </div>
    </div>
  );
}

Snippet provenance

lines 1–147 · v1.0.0
v1.0.0Motif Studio2026-09-10the only version the catalog records for this asset

No changelog entry mentions “Draw-on-scroll Path”, so the catalog records a single version for it.

Every line above is attributed to the single version this catalog records — we keep no per-line history, so no per-line attribution is invented. See the provenance page for the rule and the gaps.

Review notes · anchored to code lines

Threads attach to a line number in this asset's snippet, so a remark about the focus trap stays next to it.

demo · stored in this browser

Loading notes…

The snippet on this page is 147 lines long, so anchors run 1–147. Notes are per-asset and per-browser; a shared review thread is a server feature, and this panel is the local stand-in that proves the anchoring works.

Dependency-aware copy: zero packages to install — paste and run. All markup is original Motif UI content (MIT).

Course rail — understand it before you ship it

Theme Studio preview

Theming example — two token themes

Assets are token-driven (100% design-token driven). Here the same scene runs under two theme presets from the token sheet.

Midnight / violet

Signature curve

cleared · entered view 0×

A single curve that draws itselfA stroked path that rises from the lower left, loops once and settles near the top right. It draws when it enters view and can be redrawn with the button below.
measuring the path…
  • · One stroked path, 9 curve segments, drawn at 1.6px on a 210×128 grid
  • · It traces when the frame scrolls into view, and again whenever you press Draw
  • · dashoffset does the work, so nothing re-lays out while it draws

A decoration nobody can perceive is still a decoration: the description inside the SVG carries the same content, the buttons work whether or not the path ever draws itself, and reduced motion skips the 1200ms entirely.

--accent 262 · dark surfaces

Bone / amber

Signature curve

cleared · entered view 0×

A single curve that draws itselfA stroked path that rises from the lower left, loops once and settles near the top right. It draws when it enters view and can be redrawn with the button below.
measuring the path…
  • · One stroked path, 9 curve segments, drawn at 1.6px on a 210×128 grid
  • · It traces when the frame scrolls into view, and again whenever you press Draw
  • · dashoffset does the work, so nothing re-lays out while it draws

A decoration nobody can perceive is still a decoration: the description inside the SVG carries the same content, the buttons work whether or not the path ever draws itself, and reduced motion skips the 1200ms entirely.

--accent 40 · paper surfaces

90-second read

Usage recipe — where this fits

Use it as the signature of a single screen — a hero backdrop, an entrance, a transition. One signature per screen; everything else stays quiet.

Compose it with calm content around it: the motion earns attention only when the layout does not compete for it.

belongs in animatedscroll behaviourclick behaviour

Cost honesty

Performance note

2 KB gzipcompositor-bound — motion runs on transform/opacity layers; the cost scales with layer count and blur radius.

Cheaper alternative — the static preview variant removes the animation loop and keeps the layout — a quieter, cheaper sibling.

What it needs

Browser support strip

CSS transformsopacity compositingcustom propertiesprefers-reduced-motionwill-changeall evergreen browsers

No polyfills ship with the asset — if a listed feature is missing in a target browser, the graceful fallback is the static layout.

prefers-reduced-motion

Reduced-motion fallback

With prefers-reduced-motion: reduce, the animation loop and travel are removed; state changes keep working through opacity and colour (≤ 300ms). The demo you see above honours the switch — try it in your OS settings and the loop will quiet down.

Design rule: the reduced branch is a second design, not a stripped page — every state change stays visible.

Pressable step-through

Keyboard walk demo

Step through what a keyboard user experiences with this asset.

1

Tab to the scene — motion is paused or non-essential for keyboard users

Auto-suggested

Composition map — what pairs well

One original micro-case

Inspiration context

The hero that held attention for one beat longer

A marketing page's hero used a stock fade-in that finished in 200ms — invisible to the eye, useless to the story. Re-timed with a slow settle (0.6s, ease-out-quart) and one typographic wipe, the hero read as 'alive' without a single new asset. The change was purely a curve and a delay.

Written in-house — no screenshots, no borrowed imagery. The pattern, not the pixels.

Every version, why

Changelog — this asset

v1.0.02026-09-10

Current release — this page documents the asset as shipped.

v1.0.02026-08-18

Token pass: colours and radii moved to the design-token sheet; a11y score raised to the current bar.

v0.1.02026-07-02

Initial release to the library — original markup, MIT licensed.

30-day sparkline

Copy history

220copies this month

Sample series from this asset's usage fingerprint · last 12 days shown.

Future queue

Community remixes

Queue opens after launch. Remixes arrive as alternate versions of this asset — same job, different voice — submitted by users and audited by the studio before they appear beside the original.

0 remixes yetaudited by studiocredit + link back to the remixer

Star / favourite

Save this asset

Your collection is stored in this browser (localStorage) — no account needed.

Build a page around it

Pairs well with a prompt

This asset belongs inside a bigger build — here is the prompt that would generate a page containing it:

Motion-spec page — the animation before the layout

Spec sheet · Timing table · Easing curves

beta

Exact tree

Bundled dependencies — disclosed

draw-path.tsx6.0 KB raw · ~1 KB gzip
(no runtime dependencies)the CSS ships with the snippet

Full snippet ≈ 6.0 KB raw, ~1 KB gzip — before any framework you already load.

Download

Export as single file

Grab the asset as one file, ready to paste into your project.

Files are generated in your browser from the snippets on this page — nothing leaves the tab.

Scale, not clutter

Sizing system — three densities

Density is a token decision, not a per-page override — pick one density per product surface and hold it. Active: Default.

Runnable copy

Open in a sandbox

Opens this asset in a new tab with its stylesheet injected — a real, editable HTML document in your browser. No account, no upload.

If the tab is blocked, use the single-file export instead — same content, saved locally.

Written version first

Tutorial transcript

This asset does not have a video yet — so the written version stands in: the code line walk below narrates the snippet line by line, and the design rationale on this page explains the default decisions. When a video ships, this exact panel hosts its full transcript.

video: not yettranscript: line walk belowformat: markdown, searchable

Annotated snippet

Code line walk

The lines that matter, with the reason they matter. Click one:

Trade-off, visible

Size vs. quality slider

~2 KB~6 KB~12 KB

Standard · CSS + hover states

~6 KB

adds transitions, focus-visible and reduced-motion rules

The slider is honest: the slim tier has no JS, the pro tier pays for behaviour. Start slim, upgrade only the surfaces that need it.

HTML → React, priced

Stack-switch cost note

Taking the HTML/CSS version into a React component costs real work — and the cost is predictable:

Event wiring

Hover, focus and click become handlers — the CSS stays, the state appears.

Props for the knobs

Every inline value that should vary becomes a prop with a default — the defaults must match the CSS exactly.

The estimate

A clean port of this asset is 20–45 minutes for a React developer — the 0-character stylesheet is the easy half.

Find it the way you say it

Tag synonyms

Search on this site resolves synonyms globally — "dropdown", "select" and "picker" land on the same asset, so you never need to know the catalog's internal vocabulary.

When to pick which

Sibling comparison

Data table — data table
CompareDraw-on-scroll PathAurora VeilHalo Trail
KindAnimatedAnimatedAnimated
Bundle2 KB gzip2.6 KB gzip5.8 KB gzip
a11y95/100100/10093/100
Dependenciesnonenonenone
Copies / mo2208,9406,330
Interactionsscroll, clickscrolldrag, hover

The honest verdict — Draw-on-scroll Path is the lighter default here; reach for Aurora Veil when its extra weight buys an interaction this one lacks.

Read next — two guides and a prompt

picked by tag overlap, not by hand

How these three were chosen: essays scored on shared tags (2 and 1 matches), then prompt scored on block/vibe overlap (0 matches). The rule lives in src/lib/spine.ts, so the same asset always links to the same three pages and a second reader can reproduce the choice.

–remixes · this browser

The counter is a note to yourself — it adds one each time you tap, in motif:remix-count:v1, and goes nowhere. A real, public remix count would need a server and accounts; this site has neither, and it would rather say that than print a number it cannot own.

Was this helpful?