Workspace / effect / html-in-canvas

Bend Scroll

Folds the top and bottom of your live HTML over straight virtual edges, like scrolling on the face of a cube.

Workspaceeffecthtml-in-canvas

npx shadcn@latest add @pax-sh/bend-scroll-reactlocal only

Tier: high. Reduced motion: flat scroll

BendScroll.tsx
"use client";

import { useEffect, useRef } from "react";
import { bendScrollEffect } from "@pax-sh/effects";

export interface BendScrollProps {
  className?: string;
  reducedMotion?: boolean;
  tier?: "low" | "medium" | "high";
  children?: React.ReactNode;
}

export function BendScroll(props: BendScrollProps) {
  const rootRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const target = rootRef.current;
    if (!target) return;
    const instance = bendScrollEffect.mount(target, {
      className: props.className,
      reducedMotion: props.reducedMotion,
      tier: props.tier,
    });
    return () => instance.dispose();
  }, [props.className, props.reducedMotion, props.tier]);

  return (
    <div ref={rootRef} className={props.className} data-pax-effect="bend-scroll">
      {props.children}
    </div>
  );
}