Render Canvas

PreviousNext

A dynamic animated canvas component that renders trails following the cursor with configurable physics and color cycling.

render-canvas-default

render-canvas-custom

Installation

pnpm dlx shadcn@latest add https://ui.dalim.in/r/styles/default/render-canvas.json

Usage

import { RenderCanvas } from "@/components/ui/render-canvas"
<div className="relative h-[500px] w-full rounded-lg border">
  <RenderCanvas className="text-purple-600" />
  <div className="relative z-10 flex h-full items-center justify-center">
    <p className="text-lg font-medium">Content over animated canvas</p>
  </div>
</div>

API Reference

RenderCanvas

Renders a dynamic canvas with animated trails.

PropTypeDefaultDescription
trailsnumber80Number of trail lines rendered.
sizenumber50Number of nodes per trail line.
frictionnumber0.5Friction applied to line movement.
dampeningnumber0.025Dampening factor for velocity transfer.
tensionnumber0.99Spring tension applied along line nodes.
lineWidthnumber10Width of the line strokes.
colorHuenumber285Base hue for HSLA stroke color.
colorSaturationnumber100Saturation of HSLA stroke color.
colorLightnessnumber50Lightness of HSLA stroke color.
opacitynumber0.025Opacity of strokes.
enableColorCyclebooleantrueEnable dynamic color cycling for trails.
colorCycleSpeednumber0.0015Speed of hue wave for color cycling.
colorCycleAmplitudenumber85Amplitude of hue wave for color cycling.
widthnumber700Canvas width in pixels.
heightnumber650Canvas height in pixels.
classNamestring""Additional Tailwind/CSS classes applied to wrapper div.