An interactive pixel grid with smooth trailing effects that lights up on hover and decays over time.
Install
Add it to your project
Run this in a project set up for shadcn/ui. It writes the files and installs the npm packages.
First time: connect the Infinity UI registry
- Create a personal token on your Tokens page.
- Put it in
.env.localasINFINITYUI_TOKEN. - Add the registry to
components.json:
{
"registries": {
"@infinityui": {
"url": "https://infinityui.io/r/{name}.json",
"headers": {
"Authorization": "Bearer ${INFINITYUI_TOKEN}"
}
}
}
}Using Claude Code, Codex, Cursor, Lovable or v0? See CLI & MCP for a setup prompt.
Code
"use client";
import { PixelCanvas } from "@/components/ui/pixel-canvas";
function CursorHint() {
return (
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
<span className="text-2xl font-medium tracking-tight text-foreground/50">
Move your cursor
</span>
</div>
);
}
export function PixelCanvasDemo() {
return (
<div className="relative h-full w-full overflow-hidden bg-white dark:bg-[#171717]">
<PixelCanvas
colors={["#e879f9", "#a78bfa", "#38bdf8", "#22d3ee"]}
speed={0.02}
/>
<CursorHint />
</div>
);
}
export function PixelCanvasTrailDemo() {
return (
<div className="relative h-full w-full overflow-hidden bg-white dark:bg-[#171717]">
<PixelCanvas
variant="trail"
colors={["#f97316", "#fb923c", "#fbbf24", "#facc15"]}
gap={8}
speed={0.015}
/>
<CursorHint />
</div>
);
}
export function PixelCanvasGlowDemo() {
return (
<div className="relative h-full w-full overflow-hidden bg-white dark:bg-[#171717]">
<PixelCanvas
variant="glow"
colors={["#22c55e", "#10b981", "#14b8a6", "#06b6d4"]}
gap={10}
speed={0.01}
/>
<CursorHint />
</div>
);
}
export function PixelCanvasSubtleDemo() {
return (
<div className="relative h-full w-full overflow-hidden bg-white dark:bg-[#171717]">
<PixelCanvas
colors={["#525252", "#a3a3a3", "#737373"]}
gap={5}
speed={0.03}
/>
<CursorHint />
</div>
);
}
import * as __R from "react";
export default function __InfinityFrame() {
__R.useEffect(() => {
// Simulated cursor: a slow figure-eight, so pointer-driven effects draw something.
let t = 0;
const id = setInterval(() => {
t += 0.05;
const x = innerWidth * (0.5 + 0.32 * Math.sin(t));
const y = innerHeight * (0.5 + 0.22 * Math.sin(2 * t));
const el = document.elementFromPoint(x, y);
if (!el) return;
const init = { clientX: x, clientY: y, pageX: x, pageY: y, bubbles: true, cancelable: true, view: window };
el.dispatchEvent(new PointerEvent("pointermove", { ...init, pointerType: "mouse", isPrimary: true }));
el.dispatchEvent(new MouseEvent("mousemove", init));
}, 30);
return () => clearInterval(id);
}, []);
return (
<div style={{ position: "relative", width: "100vw", height: "100vh", display: "flex", alignItems: "center", justifyContent: "center", overflow: "hidden" }}>
<PixelCanvasDemo />
</div>
);
}




























