Staaarter

Overview Toggle Viewer

A square grid of photos. Clicking any thumbnail opens a full-screen viewer with two states, toggled by a button: a single full frame with caption and prev/next controls, or an in-place small-thumbnail overview grid of the whole set you can click to jump from without closing the viewer.

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 media-slot dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/overview-toggle-viewer.json

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

Usage

The file also exports gallery15Demo, 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 { Gallery15, gallery15Demo } from "@/components/blocks/gallery/gallery15";

export default function Page() {
  return <Gallery15 {...gallery15Demo} />;
}

Props

PropTypeDefaultDescription
headingstring"The full set"Section heading.
descriptionstring"Browse the grid, or open any frame for a closer look."Short subheading under the heading.
photosGalleryPhoto[]nonePhotos shown in the grid and the viewer.
classNamestringnoneExtra classes for the outer section element.

Types

interface GalleryPhoto {
  id: string;
  caption?: string;
  image?: MediaSlotImage;
}

Behavior notes

  • The Overview/Single view button toggles real useState between the two viewer layouts; the viewer dialog itself stays mounted the whole time, only its internal mode changes.
  • Clicking a thumbnail inside the overview grid jumps openIndex to that photo and switches straight back to single view, all without unmounting or closing the viewer.
  • The viewer's scrim uses a literal bg-black/90 rather than a semantic token, the one documented exception in this repo's block conventions for a full-screen photo overlay.