ComponentsForest Tree

Forest Tree

A soft, procedural tree made from branching strokes and tiny leaves. Tune the motion, then use it in your own React page.

Move your pointer
LIVE PREVIEW

Customize preview

GETTING STARTED

Installation

Run this in a project configured for shadcn/ui. The registry file is served by this portfolio.

Terminal
npx shadcn@latest add https://janvi-chaturvedi.me/registry/forest-tree.json
Manual installationOpen the Code tab and copy the full ForestTree.tsx source into your React project. It uses React and the browser canvas API, with no extra packages.

ADD IT TO A PAGE

Usage

After installation, import it from your configured UI alias. Place it in a relatively positioned container with a height; the canvas fills that space.

React
import ForestTree from '@/components/ui/forest-tree';

export default function Page() {
  return (
    <div style={{ position: 'relative', height: 320 }}>
      <ForestTree seed={28} />
    </div>
  );
}

The animation automatically respects prefers-reduced-motion.

API

Props

seednumber · default 17

Sets the tree shape. Reuse a seed to keep the same tree.

speednumber · default 1

Controls the speed of the sway and leaf shimmer.

swaynumber · default 1

Sets the sway strength. Use 0 to keep the tree still.

interactiveboolean · default true

Lets the tree lean gently toward pointer movement.

classNamestring · default ''

Adds a class to the canvas for custom styling.