Staaarter

Loupe Surface Studies

Square studies of material and surface texture. Opening a study hands you a loupe: a round, bounded window that magnifies whatever sits under it as you move the pointer across the image, tracked live with onPointerMove and clamped coordinates so the lens never runs off the edge of the photo.

By Staaarter Team
Gallery
Docs
Live preview

Docs

Installation

A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button, media-slot dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/loupe-surface-studies.json

Prefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/gallery/gallery4.tsx instead.

Usage

The file also exports gallery4Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.

import { Gallery4, gallery4Demo } from "@/components/blocks/gallery/gallery4";

export default function Page() {
  return <Gallery4 {...gallery4Demo} />;
}

Props

PropTypeDefaultDescription
headingstring"Surface Studies"Section heading above the grid.
descriptionstring"Close studies of material and texture. Move the loupe across the image to magnify it."Short supporting copy under the heading.
studiesSurfaceStudy[]noneThe surface studies, rendered as a grid in the order passed in.
classNamestringnoneExtra classes for the outer section element.

Types

type SurfaceStudy = {
  title: string;
  material: string;
  image: { src: string; alt: string };
};

Behavior notes

  • The loupe is real pointer-tracked state, not a hover-only CSS effect: onPointerMove reads the bounded container's getBoundingClientRect() on every move, clamps the local x/y to the container's bounds, and stores it in useState.
  • The lens itself is an absolutely-positioned circular div whose left/top are clamped a second time so the ~150px window always stays fully inside the container, even when the pointer sits at the very edge.
  • Magnification is a plain, oversized duplicate <img> inside the lens, offset by a negative left/top computed from the clamped pointer position times a fixed 2.5x zoom scale, no canvas or WebGL involved.
  • The lens hides on pointer leave and resets whenever you move to a different study via the prev/next controls or arrow keys.