Hero Parallax
- Source
- Aceternity UI ↗
- Author
- Aceternity UI
- Licence
- Aceternity UI licence (free component)
Loading…
Scroll inside the stage and three rows of product shots tilt flat and slide in opposite directions.
Code
"use client";
import React, { useEffect, useRef, useState } from "react";
import { HeroParallax } from "@/lab/aceternity/ui/hero-parallax";
/** Width the original layout was designed for; the stage zooms it to fit. */
const DESIGN_WIDTH = 1440;
export default function HeroParallaxDemo() {
const scrollRef = useRef<HTMLDivElement>(null);
const [zoom, setZoom] = useState(0.4);
useEffect(() => {
const el = scrollRef.current;
if (!el) return;
const ro = new ResizeObserver(([entry]) => {
setZoom(entry.contentRect.width / DESIGN_WIDTH);
});
ro.observe(el);
return () => ro.disconnect();
}, []);
return (
<div
ref={scrollRef}
className="relative h-full w-full overflow-y-auto overflow-x-hidden bg-white dark:bg-neutral-950"
>
<div style={{ zoom, width: DESIGN_WIDTH }}>
<HeroParallax products={products} container={scrollRef} />
</div>
</div>
);
}
const products = [
{
title: "Moonbeam",
link: "https://gomoonbeam.com",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/moonbeam.png",
},
{
title: "Cursor",
link: "https://cursor.so",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/cursor.png",
},
{
title: "Rogue",
link: "https://userogue.com",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/rogue.png",
},
{
title: "Editorially",
link: "https://editorially.org",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/editorially.png",
},
{
title: "Editrix AI",
link: "https://editrix.ai",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/editrix.png",
},
{
title: "Pixel Perfect",
link: "https://app.pixelperfect.quest",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/pixelperfect.png",
},
{
title: "Algochurn",
link: "https://algochurn.com",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/algochurn.png",
},
{
title: "Aceternity UI",
link: "https://ui.aceternity.com",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/aceternityui.png",
},
{
title: "Tailwind Master Kit",
link: "https://tailwindmasterkit.com",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/tailwindmasterkit.png",
},
{
title: "SmartBridge",
link: "https://smartbridgetech.com",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/smartbridge.png",
},
{
title: "Renderwork Studio",
link: "https://renderwork.studio",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/renderwork.png",
},
{
title: "Creme Digital",
link: "https://cremedigital.com",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/cremedigital.png",
},
{
title: "Golden Bells Academy",
link: "https://goldenbellsacademy.com",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/goldenbellsacademy.png",
},
{
title: "Invoker Labs",
link: "https://invoker.lol",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/invoker.png",
},
{
title: "E Free Invoice",
link: "https://efreeinvoice.com",
thumbnail:
"https://www.aceternity.com/images/products/thumbnails/new/efreeinvoice.png",
},
];
Prompt
Build "Hero Parallax", a scroll animation. What it does: Scroll inside the stage and three rows of product shots tilt flat and slide in opposite directions. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS, using motion. Technique: the Motion library. It sits on a light background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://ui.aceternity.com/components/hero-parallax (Aceternity UI, Aceternity UI licence (free component)).