# Image gallery

A controlled image gallery with native thumbnail and previous/next navigation plus an accessible modal preview.

Access: pro. Category: Essentials. Kind: composite.

## When to use

- Use it when a page needs a controlled image gallery with native thumbnail and previous/next navigation plus an accessible modal preview.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose tidal-button instead when press, loading, success and disabled states is the actual interface need, rather than image gallery.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Image gallery

```sh
npx shadcn@latest add @tidal-pro/image-gallery
```

Stylesheets: `components/ui/tidal.css`, `components/ui/image-gallery.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/image-gallery.css";
import{TidalImageGallery}from"./components/ui/image-gallery";
export default()=><div className="tidal-scope"><TidalImageGallery currentItemId={"example"} items={[{id:"example",label:"Demo",media:"value"}]} label={"Demo"} onCurrentItemChange={() => {}}/></div>;
```

## Structured props

- `TidalImageGallery.currentItemId: string`: Required current item id value accepted by this exported component.
- `TidalImageGallery.items: ReadonlyArray<TidalImageGalleryItem>`: Required items value accepted by this exported component.
- `TidalImageGallery.label: string`: Required label value accepted by this exported component.
- `TidalImageGallery.onCurrentItemChange: (itemId: string, event: TidalImageGalleryChangeEvent, source: TidalImageGalleryChangeSource) => void`: Callback invoked when the current item change interaction is proposed.
- `TidalImageGallery.closeButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled" | "type" | "aria-disabled" | "aria-label" | "children"> | undefined`: Optional close button props value accepted by this exported component.
- `TidalImageGallery.closeButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional close button ref value accepted by this exported component.
- `TidalImageGallery.defaultOpen?: boolean | undefined` (default false): Optional default open value accepted by this exported component.
- `TidalImageGallery.dialogContentProps?: Omit<Omit<Dialog.DialogContentProps & RefAttributes<HTMLDivElement>, "ref">, "children" | "asChild"> | undefined`: Optional dialog content props value accepted by this exported component.
- `TidalImageGallery.dialogContentRef?: Ref<HTMLDivElement> | undefined`: Optional dialog content ref value accepted by this exported component.
- `TidalImageGallery.dialogNextButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled" | "type" | "aria-disabled" | "aria-label" | "children"> | undefined`: Optional dialog next button props value accepted by this exported component.
- `TidalImageGallery.dialogNextButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional dialog next button ref value accepted by this exported component.
- `TidalImageGallery.dialogPreviousButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled" | "type" | "aria-disabled" | "aria-label" | "children"> | undefined`: Optional dialog previous button props value accepted by this exported component.
- `TidalImageGallery.dialogPreviousButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional dialog previous button ref value accepted by this exported component.
- `TidalImageGallery.dir?: "ltr" | "rtl" | undefined` (default "ltr"): Optional dir value accepted by this exported component.
- `TidalImageGallery.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalImageGallery.emptyMessage?: ReactNode`: Optional empty message value accepted by this exported component.
- `TidalImageGallery.labels?: Partial<TidalImageGalleryLabels> | undefined`: Optional labels value accepted by this exported component.
- `TidalImageGallery.loop?: boolean | undefined` (default true): Optional loop value accepted by this exported component.
- `TidalImageGallery.nextButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled" | "type" | "aria-disabled" | "aria-label" | "children"> | undefined`: Optional next button props value accepted by this exported component.
- `TidalImageGallery.nextButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional next button ref value accepted by this exported component.
- `TidalImageGallery.onOpenChange?: ((open: boolean) => void) | undefined`: Callback invoked when the open change interaction is proposed.
- `TidalImageGallery.open?: boolean | undefined`: Optional open value accepted by this exported component.
- `TidalImageGallery.openButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled" | "type" | "aria-disabled" | "aria-label" | "children"> | undefined`: Optional open button props value accepted by this exported component.
- `TidalImageGallery.openButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional open button ref value accepted by this exported component.
- `TidalImageGallery.portalContainer?: HTMLElement | null | undefined`: Optional portal container value accepted by this exported component.
- `TidalImageGallery.previousButtonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled" | "type" | "aria-disabled" | "aria-label" | "children"> | undefined`: Optional previous button props value accepted by this exported component.
- `TidalImageGallery.previousButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional previous button ref value accepted by this exported component.
- `TidalImageGallery.theme?: "light" | "dark" | undefined` (default "light"): Optional theme value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/image-gallery.tsx) | [Manifest](https://tidalui.com/examples/image-gallery.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useMemo, useState } from "react";

import { TidalImageGallery, type TidalImageGalleryItem } from "./components/ui/image-gallery";

import "./components/ui/image-gallery.css";



const tidalExampleStyles = ".tidal-scope .image-gallery-demo,\n.tidal-scope .image-gallery-demo * {\n  box-sizing: border-box;\n}\n.tidal-scope .image-gallery-demo {\n  width: min(100%, 980px);\n  min-width: 0;\n  margin-inline: auto;\n  padding: clamp(8px, 3vw, 28px);\n  background: var(--t-subtle);\n  color: var(--t-ink);\n}\n.tidal-scope .image-gallery-demo-footer {\n  padding: 10px 12px 0;\n}\n.tidal-scope .image-gallery-demo-footer p {\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n  overflow-wrap: anywhere;\n}\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .image-gallery-demo * {\n    scroll-behavior: auto;\n  }\n}";

function StudyVisual({
  variant,
  label,
}: {
  variant: 1 | 2 | 3;
  label: string;
}) {
  return (
    <svg viewBox="0 0 720 440" role="img" aria-label={label}>
      <rect width="720" height="440" fill="var(--t-surface)" />
      <path
        d="M0 80H720M0 160H720M0 240H720M0 320H720M120 0V440M240 0V440M360 0V440M480 0V440M600 0V440"
        stroke="var(--t-border)"
      />
      {variant === 1 ? (
        <>
          <rect
            x="70"
            y="70"
            width="250"
            height="300"
            rx="18"
            fill="var(--t-ink)"
          />
          <rect
            x="350"
            y="70"
            width="300"
            height="82"
            rx="15"
            fill="var(--t-wash)"
            stroke="var(--t-ink)"
          />
          <rect
            x="350"
            y="174"
            width="140"
            height="196"
            rx="15"
            fill="var(--t-subtle)"
            stroke="var(--t-ink)"
          />
          <rect
            x="510"
            y="174"
            width="140"
            height="196"
            rx="70"
            fill="none"
            stroke="var(--t-ink)"
            strokeWidth="3"
          />
          <circle cx="195" cy="220" r="58" fill="var(--t-surface)" />
          <path
            d="M155 220h80M195 180v80"
            stroke="var(--t-ink)"
            strokeWidth="5"
          />
        </>
      ) : variant === 2 ? (
        <>
          <path
            d="M70 310C170 120 250 350 350 170S530 280 650 95"
            fill="none"
            stroke="var(--t-ink)"
            strokeWidth="12"
            strokeLinecap="round"
          />
          {[70, 210, 350, 510, 650].map((x, index) => (
            <g key={x}>
              <circle
                cx={x}
                cy={[310, 220, 170, 205, 95][index]}
                r="24"
                fill="var(--t-surface)"
                stroke="var(--t-ink)"
                strokeWidth="4"
              />
              <circle
                cx={x}
                cy={[310, 220, 170, 205, 95][index]}
                r="8"
                fill="var(--t-ink)"
              />
            </g>
          ))}
          <rect
            x="70"
            y="354"
            width="580"
            height="22"
            rx="11"
            fill="var(--t-wash)"
          />
          <rect
            x="70"
            y="354"
            width="440"
            height="22"
            rx="11"
            fill="var(--t-ink)"
          />
        </>
      ) : (
        <>
          {[0, 1, 2].map((column) => (
            <g key={column} transform={`translate(${75 + column * 205} 72)`}>
              <rect
                width="160"
                height="296"
                rx="18"
                fill={column === 1 ? "var(--t-ink)" : "var(--t-subtle)"}
                stroke="var(--t-ink)"
              />
              <rect
                x="26"
                y="34"
                width="108"
                height="12"
                rx="6"
                fill={column === 1 ? "var(--t-surface)" : "var(--t-ink)"}
              />
              {[76, 130, 184].map((y, index) => (
                <rect
                  key={y}
                  x="20"
                  y={y}
                  width="120"
                  height="38"
                  rx="9"
                  fill={
                    column === 1
                      ? "var(--t-surface)"
                      : index === column
                        ? "var(--t-ink)"
                        : "var(--t-surface)"
                  }
                  stroke="var(--t-border)"
                />
              ))}
              <circle
                cx="80"
                cy="260"
                r="14"
                fill={column === 1 ? "var(--t-surface)" : "var(--t-ink)"}
              />
            </g>
          ))}
        </>
      )}
    </svg>
  );
}

const STUDIES = [
  {
    id: "structure",
    label: "Structure study",
    meta: "Canvas 01",
    caption: "A modular workspace shell built from clear content zones.",
    variant: 1 as const,
  },
  {
    id: "flow",
    label: "Flow study",
    meta: "Canvas 02",
    caption: "A release path that keeps progress and checkpoints in one view.",
    variant: 2 as const,
  },
  {
    id: "index",
    label: "Index study",
    meta: "Canvas 03",
    caption: "Three compact file columns for scanning work by stage.",
    variant: 3 as const,
  },
] as const;

export function ImageGalleryDemo({
  theme = "light",
}: {
  theme?: "light" | "dark";
}) {
  const [currentItemId, setCurrentItemId] = useState("structure");
  const [open, setOpen] = useState(false);
  const [status, setStatus] = useState("Structure study is selected.");
  const items = useMemo<readonly TidalImageGalleryItem[]>(
    () =>
      STUDIES.map((study) => ({
        ...study,
        media: (
          <StudyVisual
            variant={study.variant}
            label={`${study.label}. ${study.caption}`}
          />
        ),
      })),
    [],
  );

  return (
    <section className="image-gallery-demo" aria-label="Workspace studies">
      <TidalImageGallery
        theme={theme}
        label="Workspace studies"
        items={items}
        currentItemId={currentItemId}
        onCurrentItemChange={(id) => {
          setCurrentItemId(id);
          const item = STUDIES.find((study) => study.id === id);
          setStatus(`${item?.label ?? "Image"} is selected.`);
        }}
        open={open}
        onOpenChange={(nextOpen) => {
          setOpen(nextOpen);
          setStatus(
            nextOpen ? "Expanded preview opened." : "Expanded preview closed.",
          );
        }}
      />
      <footer className="image-gallery-demo-footer">
        <p role="status" aria-live="polite">
          {status} Sample artwork. Changes stay in this preview.
        </p>
      </footer>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <ImageGalleryDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation.","Escape dismisses the open overlay where the underlying primitive supports dismissal."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

label, items, currentItemId and onCurrentItemChange are required. Each unique item supplies a string label, accessible consumer-owned media, optional thumbnail/caption/meta, disabled state, thumbnail attributes and ref. Native previous, next and roving thumbnail buttons run caller handlers first and honor prevention; Arrow/Home/End thumbnail movement follows direction and skips disabled items. Optional loop, disabled, localized labels and empty content remain consumer-owned. Inline and dialog previous/next controls have separate native attribute/ref paths so simultaneous buttons retain distinct identity and handlers. The official Radix Dialog preview supports controlled or uncontrolled open state, focus trapping, Escape, backdrop dismissal and trigger focus return, with explicit portal theme/direction/container and content/close refs. There is no autoplay, timer, image request, upload, download, route, analytics, network or storage behavior.
