Line Draw SVG

SVG path that draws itself on scroll, hover, or mount. Presets: diamond, circle, star, heart, arrow.

Last updated Mar 5, 2026

Component

Scroll to animate (diamond)

Installation

pnpm dlx shadcn@latest add "https://pulkitxm.com/components/line-draw-svg.json"

Usage

Import

Add the LineDrawSvg import.

import { LineDrawSvg } from "@/components/line-draw-svg";

Use

Use with preset and trigger.

<LineDrawSvg preset="diamond" trigger="scroll" />;

Guidelines

  • Use trigger='scroll' for scroll-triggered reveals (e.g. in long pages).
  • Use trigger='hover' for interactive icons.
  • Use trigger='mount' for immediate draw on page load.
  • Presets: diamond, circle, star, heart, arrow.
  • ease: power1.inOut, power2.inOut, elastic.out, back.out, etc.

Props

All props are optional unless marked required. Use these to customize every aspect of the component.

PropTypeDefaultDescription
pathstringCustom SVG path (d attribute). Overrides preset.
presetstring"diamond"Preset shape: "diamond", "circle", "star", "heart", "arrow".
trigger"scroll" | "hover" | "mount""scroll"When to draw: "scroll", "hover", or "mount".
durationnumber1Animation duration in seconds.
easestring"power2.inOut"GSAP ease: power1.inOut, power2.inOut, elastic.out, back.out, etc.
scrubboolean | number1ScrollTrigger scrub (true = smooth, number = seconds).
startstring"top 80%"ScrollTrigger start.
endstring"top 20%"ScrollTrigger end.
widthnumber120SVG width in pixels.
heightnumber120SVG height in pixels.
strokeWidthnumber2Stroke width in pixels.
strokeClassNamestringClasses for the path stroke (e.g. text-amber-500).

Examples

Scroll (diamond)

Diamond draws on scroll into view.

Scroll to animate (diamond)

import { LineDrawSvg } from "@/components/line-draw-svg";

<LineDrawSvg preset="diamond" trigger="scroll" />;

Hover (star)

Star draws when user hovers.

Hover to animate (star)

import { LineDrawSvg } from "@/components/line-draw-svg";

<LineDrawSvg preset="star" trigger="hover" />;

Mount (circle)

Circle draws immediately on mount.

Animates on mount (circle)

import { LineDrawSvg } from "@/components/line-draw-svg";

<LineDrawSvg preset="circle" trigger="mount" />;

Size & easing

Larger size, thicker stroke, elastic easing.

Scroll to animate (diamond)

import { LineDrawSvg } from "@/components/line-draw-svg";

<LineDrawSvg
  preset="heart"
  duration={1.5}
  ease="elastic.out"
  width={160}
  height={160}
  strokeWidth={3}
/>;

Custom path

Custom SVG path and stroke color.

Scroll to animate (diamond)

import { LineDrawSvg } from "@/components/line-draw-svg";

<LineDrawSvg
  path="M10 50 L90 50"
  trigger="mount"
  strokeClassName="text-amber-500"
/>;

Made with ❤️ by Pulkit & Cursor :)

© 2026 Pulkit. All rights reserved

DMCA Verified

Last updated: