The TunnelScroll component acts as an immersive page wrapper. Instead of the page scrolling down normally, the component maps your scroll progress to the Z-axis of a 3D camera.
It wraps your standard React children inside @react-three/drei's <Html> projection, rendering them as standard DOM elements that live physically inside the 3D space of the tunnel!
Live Preview
[!IMPORTANT] Fixed Widths: Because the children are projected into 3D space, standard CSS responsive behaviors (like
w-fullexpanding infinitely) can break the projection and cause the elements to size incorrectly. Always provide fixed maximum widths (e.g.,w-[800px]orw-[1000px]) to the top-level children you pass into the wrapper.
Usage Guide
1. Import the Component
Import the component into your React or Next.js page:
import { TunnelScroll } from "@/components/creative/tunnel-scroll";
2. Implementation Example
Render the component and customize its behavior by passing props:
import { TunnelScroll } from "@/components/creative/tunnel-scroll";
export default function Example() {
return (
<div className="w-full flex items-center justify-center p-8">
<TunnelScroll
spacing{10}
tunnelColor="example"
>
<div>Content goes here</div>
</TunnelScroll>
</div>
);
}