Kinetic UI
Back to Introduction
Media

SVG Path Draw

An animated SVG path tracing component that automatically plays when scrolled into view.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add svg-path-draw
SVG Path Draw

SVG Path Tracing

A buttery-smooth path drawing animation that triggers on scroll.

Installation

npx kinetic-ui-cli@latest add svg-path-draw

How It Works

The SvgPathDraw component leverages framer-motion's ability to natively animate SVG attributes. Specifically, it manipulates the stroke-dasharray and stroke-dashoffset CSS properties behind the scenes via the pathLength motion value. We wrap the container in a useInView hook with a negative margin so that the drawing animation triggers precisely when the component enters the user's viewport, making it perfect for hero sections or storytelling graphics.

Usage Guide

1. Import the Component

Import the component into your React or Next.js page:

import { SvgPathDraw } from "@/components/creative/svg-path-draw";

2. Implementation Example

Render the component and customize its behavior by passing props:

import { SvgPathDraw } from "@/components/creative/svg-path-draw";

export default function Example() {
  return (
    <div className="w-full flex items-center justify-center p-8">
      <SvgPathDraw
        path="example"
        strokeColor="example"
        strokeWidth{10}
      />
    </div>
  );
}
Performance Notes
  • Uses CSS hardware acceleration via GPU transform-binds.
  • Damped interpolation minimizes paint-redraw flashes.
  • Tree-shakable import: only compiles elements requested.
Accessibility Notes
  • Full keyboard focus-ring navigation support (`Tab`/`Shift+Tab`).
  • ARIA roles mapped correctly for assistive screen readers.
  • Respects `prefers-reduced-motion` system toggles.