Xzero UI
Pro library

Photo gridPro

Pinch through zoom levels and open any photo straight from its cell.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/photo-grid
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/photo-grid

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { PhotoGrid, type GridPhoto } from "@/components/xzero/photo-grid/photo-grid";

export function Album({ photos }: { photos: GridPhoto[] }) {
  return (
    <PhotoGrid
      title="September"
      photos={photos}
      defaultColumns={4}
      onFavoriteChange={(id, favorite) => saveFavorite(id, favorite)}
    />
  );
}

API reference

PhotoGrid

A photo library grid with pinch or button zoom between column counts, favorites, and a full-screen viewer that grows from the tapped cell.

PropTypeDefaultDescription
photos (required){ id: string; src: string; srcSet?: string; alt: string; width: number; height: number; title: string; detail?: string }[]–Photos in order. width and height are the intrinsic size; detail is a short line in the viewer, such as the date.
title (required)string–Names the library, such as a month or album.
zoomLevelsnumber[][5, 3, 2]Column counts the zoom steps between.
defaultColumnsnumber3Initial column count.
onColumnsChange(columns: number) => void–Called when the zoom level changes.
defaultFavoritesstring[]–Ids favorited at mount.
onFavoriteChange(id: string, favorite: boolean) => void–Called when a photo is favorited or unfavorited.
onViewerChange(id: string | null) => void–Called with the photo id when the viewer opens and null as it starts to close.
classNamestring–Extra class on the root.

Keyboard interactions

KeysAction
Arrow keysMove focus between photos in the grid.
PageUp / PageDown / Home / EndJump by three rows or to the first or last photo.
+ / -Zoom in or out a level around the focused photo.
Enter / SpaceOpens the focused photo in the viewer.
ArrowLeft / ArrowRight / Home / EndIn the viewer, change photo.
EscapeCloses the viewer.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in galleries

Guidance for AI tools

Photo grid: Pinch through zoom levels and open any photo straight from its cell. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components