SVG Pixel Reveal
An SVG pixel filter dissolves into a crisp photograph as it enters the scroll area.
Scroll inside the preview to reveal the photograph.
Component preview
Install using CLI
npx shadcn@latest add "https://www.obsidianui.dev/r/svg-pixel-reveal.json"Usage
Code
"use client";
import { useRef } from "react";
import { SvgPixelReveal } from "@/components/block/svg-pixel-reveal";
export default function Demo() {
const scroller = useRef<HTMLDivElement>(null);
return <div ref={scroller} tabIndex={0} aria-label="Scroll effect preview" className="relative h-[400px] overflow-y-auto overscroll-contain" style={{ containerType: "size" }}>
<div className="flex h-[45cqh] items-center justify-center">Scroll to reveal</div>
<SvgPixelReveal src="https://pub-830233752de349e29c6104a501b309d4.r2.dev/effects/svg-pixel-reveal/svg-pixel-reveal-img01.png" alt="Landscape photograph" scroller={scroller} start="top 35%" style={{ width: "86%", height: "70cqh", margin: "0 auto" }} />
<div className="h-[50cqh]" />
</div>;
}Install Manually
1
Install dependencies
npm install gsap
2
Copy the source code
Copy into components/block/svg-pixel-reveal.jsx
3
Add the CSS file
Copy into lib/effects/svg-pixel-reveal/styles.css
Preview behavior
Scroll inside the preview to reveal the photograph. The effect stays inside its container and respects reduced motion preferences.
Last updated on