Skip to content

Horizontal 3D Gallery

Vertical scroll pans a perspective gallery sideways.

CSS 3DTypeScriptLight + AMOLED
Example.tsx
import { Animations3D } from "@/components/3d/animations";

export default function Example() {
  return (
    <div style={{ height: 480 }}>
      <Animations3D
        variant="gallery"
        theme="light"
      />
    </div>
  );
}

Deps: three, @react-three/fiber, @react-three/drei, framer-motion

Installation

Install the runtime dependencies, then copy the component module (and the shared 3D core when the component uses WebGL).

terminal
npm install three @react-three/fiber @react-three/drei framer-motion

# Copy the component module
cp -r src/components/3d/animations <your-project>/src/components/3d/animations

Dependencies: three, @react-three/fiber, @react-three/drei, framer-motion

Usage

Every category module exposes one typed component. Pick an implementation with variant and pass props grouped by concern.

Example.tsx
import { Animations3D } from "@/components/3d/animations";

export default function Example() {
  return (
    <div style={{ height: 480 }}>
      <Animations3D
        variant="gallery"
        theme="light"
      />
    </div>
  );
}

React implementation

With every prop set explicitly. The complete, copyable source of src/components/3d/animations/index.tsx is available in the playground’s Source tab.

Example.tsx
import { Animations3D } from "@/components/3d/animations";

export default function Example() {
  return (
    <div style={{ height: 480 }}>
      <Animations3D
        variant="gallery"
        theme="amoled"
        color="#7777ff"
        intensity={1}
        quality="medium"
      />
    </div>
  );
}

Next.js implementation

This component is DOM based, but it is still code-split with next/dynamic so interaction code ships only where it's used.

app/horizontal-3d-gallery/page.tsx
// app/horizontal-3d-gallery/page.tsx  (Next.js App Router)
"use client";

import dynamic from "next/dynamic";

// Heavy interactive code is split into its own chunk.
const Animations3D = dynamic(
  () => import("@/components/3d/animations").then((m) => m.Animations3D),
  { ssr: false, loading: () => <div aria-busy="true" style={{ height: 480 }} /> },
);

export default function Page() {
  return (
    <main>
      <div style={{ height: 480 }}>
        <Animations3D
          variant="gallery"
          theme="light"
        />
      </div>
    </main>
  );
}

TypeScript interfaces

Horizontal3DGallery.types.ts
export type Theme = "light" | "amoled";

export interface Horizontal3DGalleryProps {
  /** Which Scroll-based 3D Animations implementation to render */
  variant: "gallery";
  theme: Theme;

  /* Visual */
  color?: string; // default "#7777ff"

  /* Animation */
  intensity?: number; // 0.2–2, default 1

  /* Rendering */
  quality?: "low" | "medium" | "high"; // default "medium"
}

Props reference

PropTypeDefaultGroupDescription
variant"gallery"—CoreSelects the implementation.
theme"light" | "amoled"—CoreThemes surfaces, materials and lighting.
colorstring (hex)"#7777ff"VisualColor
intensitynumber1AnimationIntensity (0.2 – 2)
quality"low" | "medium" | "high""medium"RenderingQuality preset

Customization

Colour props accept any hex string. Content props accept plain strings. Every value shown in the playground maps 1:1 to a prop, so you can design visually and copy the generated code. Use Share to send a pre-configured link or Export to download the configuration JSON.

Customized.tsx
import { Animations3D } from "@/components/3d/animations";

export default function Example() {
  return (
    <div style={{ height: 480 }}>
      <Animations3D
        variant="gallery"
        theme="light"
        color="#ff5a36"
      />
    </div>
  );
}

Animation settings

  • intensityIntensity · 0.2–2

All motion is suspended when prefers-reduced-motion is on.

Theme support

Pass theme="light" or theme="amoled". Surfaces, borders, shadows and text switch via CSS variables (--bg, --card, --fg, --border, --accent). AMOLED uses true #000000. Use the theme switch in the playground toolbar to preview both.

Responsive behavior

The component fills its parent, so size it with the container. Use the playground’s desktop / tablet / mobile selector to test. Layouts use fluid widths and container-relative sizing.

Accessibility notes

  • — The scroll area is focusable and responds to arrow keys and Page Up/Down.
  • — Progress is exposed visually and never gates content.
  • — Scroll-linked effects are subtle by design; reduce intensity in the controls.

Performance notes

  • — Scroll progress is a motion value read inside useFrame — no React state per scroll tick.
  • — Scenes only render while visible.
  • — Sticky stage avoids scroll-jacking.