Motion Kit

Canvas

Interactive Grid

Physics-based grid simulation that distorts an image in response to cursor movement. Each grid cell tracks mouse velocity and decays back to rest over time.

  • lit
  • ogl

Preview

Physics-based grid simulation — move your cursor over the image to warp it. Each cell tracks mouse velocity and relaxes back to rest.
Attributes

Installation

pnpm dlx shadcn@latest add https://motion-kit-astro.vercel.app/r/interactive-grid.json

Usage

---
import "@/components/motion-kit/interactive-grid-element.ts";
---

<motion-interactive-grid
  src="/path/to/image.jpg"
  grid={15}
  mouse-size={0.15}
  strength={0.35}
  relaxation={0.9}
  class="w-full h-[500px]"
/>

API Reference

Attribute Type Default
src The image source URL to apply the distortion effect to. string
grid Grid resolution — number of cells per row/column. Higher values create finer distortion detail. number 15
mouse-size Radius of mouse influence as a fraction of the grid size (0–1). number 0.15
strength Strength of the distortion effect. Higher values produce more dramatic warping. number 0.35
relaxation How quickly cells return to rest after the cursor leaves (0–1). Values closer to 1 decay more slowly. number 0.9