Parallax Gallery
A framed gallery with rotating photographs, moving side thumbnails, and scroll snapping.
Scroll inside the preview to move through the photographs.
Component preview
Install using CLI
npx shadcn@latest add "https://www.obsidianui.dev/r/parallax-gallery.json"Usage
Code
"use client";
import { useRef } from "react";
import { ParallaxGallery } from "@/components/block/parallax-gallery";
const images = [
"https://pub-830233752de349e29c6104a501b309d4.r2.dev/effects/parallax-gallery/parallax-gallery-img01.jpg",
"https://pub-830233752de349e29c6104a501b309d4.r2.dev/effects/parallax-gallery/parallax-gallery-img02.jpg",
"https://pub-830233752de349e29c6104a501b309d4.r2.dev/effects/parallax-gallery/parallax-gallery-img03.jpg",
"https://pub-830233752de349e29c6104a501b309d4.r2.dev/effects/parallax-gallery/parallax-gallery-img04.jpg"
];
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" }}>
<ParallaxGallery images={images} scroller={scroller} viewportHeight="100cqh" frameWidth={240} frameHeight={280} thumbnailWidth={90} thumbnailHeight={130} />
</div>;
}Install Manually
1
Install dependencies
npm install gsap motion
2
Copy the source code
Copy into components/block/parallax-gallery.jsx
Preview behavior
Scroll inside the preview to move through the photographs. The effect stays inside its container and respects reduced motion preferences.
Last updated on