seednumber · default 17Sets the tree shape. Reuse a seed to keep the same tree.
A soft, procedural tree made from branching strokes and tiny leaves. Tune the motion, then use it in your own React page.
GETTING STARTED
Run this in a project configured for shadcn/ui. The registry file is served by this portfolio.
npx shadcn@latest add https://janvi-chaturvedi.me/registry/forest-tree.jsonForestTree.tsx source into your React project. It uses React and the browser canvas API, with no extra packages.ADD IT TO A PAGE
After installation, import it from your configured UI alias. Place it in a relatively positioned container with a height; the canvas fills that space.
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
seednumber · default 17Sets the tree shape. Reuse a seed to keep the same tree.
speednumber · default 1Controls the speed of the sway and leaf shimmer.
swaynumber · default 1Sets the sway strength. Use 0 to keep the tree still.
interactiveboolean · default trueLets the tree lean gently toward pointer movement.
classNamestring · default ''Adds a class to the canvas for custom styling.