ReactHive

Lens Slider

Component 1

About

One screen of projects with a window in the middle showing the same picture, closer. Swipe or scroll and the next project wipes in over the screen while, a beat later, it wipes in inside the window, like two panes of glass passing. It loops; the window drifts with the pointer.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Lens Slider to your project and fits it to your theme.

Code

How Lens Slider is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { LensSlider } from "@/components/ui/lens-slider";

const settings = {
  zoom: 1.7
};

/* The demo's Google Fonts. In a Next.js app, use next/font/google instead. */
if (typeof document !== "undefined" && !document.getElementById("lens-slider-fonts")) {
  const style = document.createElement("style");
  style.id = "lens-slider-fonts";
  style.textContent = "@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@100..900&display=swap'); .rh-inter-tight { font-family: 'Inter Tight', sans-serif; }";
  document.head.appendChild(style);
}

const objects = [
  {
    "name": "object-chrome",
    "title": "Chrome Bloom",
    "alt": "A twisting chrome form floating on deep green",
    "caption": "Polished metal, poured and caught mid-turn",
    "ink": "light",
    "width": 2000,
    "height": 1125,
    "src": "https://cdn.21st.dev/assets/mirror/ba/ba0923fc111c3d32fefbbb75a3c4d1adac5852c5ad041fae31de78b01804ce67.webp"
  },
  {
    "name": "object-spheres",
    "title": "Soft Pair",
    "alt": "A white half shell beside two spheres of blue fur",
    "caption": "One shell, two spheres, a lot of fur",
    "ink": "dark",
    "width": 2000,
    "height": 1125,
    "src": "https://cdn.21st.dev/assets/mirror/a4/a4dde246565e0d543ceb846ece1d43248d354a8195f6fa6ca6300ce8dfa8f78d.webp"
  },
  {
    "name": "object-reach",
    "title": "Reach",
    "alt": "A painting of a figure raising their hands in a swirl of teal and cream",
    "caption": "Paint pushed around until a figure appears",
    "ink": "light",
    "width": 2000,
    "height": 1191,
    "src": "https://cdn.21st.dev/assets/mirror/f2/f29b5439e4e6393fcd8537798520a6d74bf85dde3882f8696510202131f081b5.webp"
  },
  {
    "name": "object-arch",
    "title": "Green Arch",
    "alt": "A rippling green arch on a pale green ground",
    "caption": "An arch that never sits still",
    "ink": "dark",
    "width": 2000,
    "height": 1125,
    "src": "https://cdn.21st.dev/assets/mirror/a9/a935e695060930cd26a500c374ad6ab10a24bce306676ed486487ec9e1f525cf.webp"
  },
  {
    "name": "object-ball",
    "title": "Match Point",
    "alt": "A fuzzy pink tennis ball in mid air",
    "caption": "Pink, fuzzy and in mid air",
    "ink": "dark",
    "width": 2000,
    "height": 1125,
    "src": "https://cdn.21st.dev/assets/mirror/7c/7c67ee8a97b8c19818beb23ab7e9d1b5e615aa4f43187c6f8386173afd932be8.webp"
  }
];

const type = { className: "rh-inter-tight", style: { fontFamily: "'Inter Tight', sans-serif" } };

function DemoContent(props: Partial<typeof settings> = {}) {
  const v = { ...settings, ...props };
  const slides = objects.map((p) => ({ src: p.src, alt: p.alt, title: p.title, caption: p.caption, ink: p.ink as "light" | "dark" }));
  return (
    <main className={`${type.className} h-svh overflow-hidden bg-black text-white`}>
      <LensSlider slides={slides} zoom={Number(v.zoom)} />
    </main>
  );
}

/** The demo in its own colours, filling the frame. */
export default function Demo(props: Partial<typeof settings> = {}) {
  return (
    <div className="min-h-svh w-full" style={{ background: "#000000" }}>
      <DemoContent {...props} />
    </div>
  );
}

More by ReactHive

View all
  • Card Deal

    Card Deal

    78
  • Step Stack

    Step Stack

    58
  • Arc Gallery

    Arc Gallery

    39
  • Fluid Type

    Fluid Type

    33
  • Card Pack

    Card Pack

    28
  • Satin

    Satin

    19
  • Flap Board

    Flap Board

    9
  • Mercury Clock

    Mercury Clock

    8

Explore more

Part of ReactHive UI — browse the full library on 21st.dev.