Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Lightbox Gallery Block for React

Nine pictures of a photography studio's year on shared hairlines, a featured frame and a caption under each, where every frame opens one viewer dialog with the whole picture, its credit, Previous and Next, a counter, arrow keys and a swipe.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A lightbox gallery for React with Base UI, for Tarnlight, a photography studio for architects and makers. A compact header sits over nine frames on shared hairlines that run from rail to rail and end the block: a featured frame two cells wide and two tall, then eight more, each with its title, place and year as a caption. Every frame is a button that opens one viewer dialog: the whole picture, uncropped at its own ratio, its title, place, year and credit, Previous and Next buttons, a "3 of 9" counter, the arrow keys (Home and End too) and a swipe on touch screens. Closing it returns focus to the frame of the picture last shown. On a phone the viewer fills the screen. The pictures are drawn, not photographed: a small kit of scenes (hills, a mountain range, a lake, facades, a room, a chair and a lamp on a plinth, a tile pattern) in your theme's own greys, light in a light theme and low-key in a dark one, each a few lines of data you swap for your photographs. It's built from Dialog, Button and Guides, with CSS transitions and your theme's tokens for every colour. The studio, places, people and credits are made up for the example.

FAQ

How do I use my own photographs?

Each picture in PICTURES has a title, a place, a year, a credit, a description and a ratio; add your image's address to it. Then replace the Scene in the frame with <img alt="" className="size-full object-cover" src={…} /> (the button and the caption already name it), and the one in the viewer with an <img> that has alt set to the picture's description and object-contain. The comment above Scene says where. Set ratio to the photograph's width over its height, so the viewer shows it whole.

How are the pictures drawn?

Each one is a scene: a kind (hills, range, lake, facade, room, chair, lamp or pattern) and three numbers: light (where the sun, the window or the key light is, across the picture), horizon (where the ground meets the sky or the floor meets the wall) and a seed that moves ridgelines, lights windows and turns tiles. Each kind is a function that returns the picture as SVG paths, each painted with one of a few inks mixed from your theme's colours, so two facades with different numbers are two different buildings. Nothing is random at render time: the same seed draws the same picture on the server and in the browser.

Is there one viewer or one per picture?

One. The block keeps the open state and the picture shown, so a frame, Previous, Next, an arrow key or a swipe only changes which picture it shows. Previous and Next wrap around. The viewer's title, counter and credit follow, the picture fades in (still with reduced motion), and a polite status line says "Lamp No. 4, 7 of 9" for a screen reader. The picture itself is an image named by its description.

How does it work with a keyboard?

Tab reaches each frame and Enter or Space opens the viewer. Inside, the arrow keys move to the previous and next picture (mirrored in a right-to-left layout), Home and End jump to the first and the last, Tab cycles through the close button, Previous and Next, and Escape closes. Focus then returns to the frame of the picture you were looking at, not the one you opened, so step on three pictures and close and you land on that frame. DialogContent takes finalFocus, a function that returns that frame.

How does it fit on a phone?

The frames go two across, with the featured one across both columns. The viewer fills the screen: the counter and the close button at the top, the picture as large as it fits in between, and the caption with full-width Previous and Next buttons at the foot, within reach of a thumb. A horizontal swipe over the picture steps through them too.

Does it follow my theme?

Yes. Every colour in the pictures is mixed from your theme's foreground, background and muted tokens: in a light theme they print dark on pale grey, in a dark theme they turn low-key with lamps and skies still light. The block ends on its last row of frames with no closing line, so the next section's top rule closes it, and the viewer uses your theme's dialog surface.

  • Pro

    Sixteen drawn thumbnails on shared hairlines, eight across, where choosing one opens a preview band straight under its row with the whole picture, its source, Previous, Next and Close, without changing the block's height.

  • Pro

    A quiet grid of twenty-four drawn concrete-architecture plates, eight to a page on shared hairlines, with a title and year that appear on hover and focus and the catalog pagination in a band that ends the block.

  • Pro

    Thumbnail Strip Gallery

    Stage and thumbnails

    A viewer for a lighting shop: a framed 4:3 stage with Previous and Next, its caption beside it, and a scrollable strip of twelve thumbnails whose arrow keys step through the pictures.

  • Pro

    Carousel Gallery

    Carousels and slides

    Nine drawn trail pictures in a ruled band for a trail-guide app, three wide with the next one cut off at the rail, turned with buttons, dots and the arrow keys, under a heading row with a live counter.

  • Pro

    Profile Drawer Team

    Lists and directories

    Eight people of a design agency as rows that each open one side drawer with a quote, a bio and three career figures, with Previous and Next buttons that step through the team without closing the drawer.

  • Pro

    A showcase hero for a design studio: a centered headline with a Shine Button, over a masonry wall of six projects drawn in greyscale inside a hairline frame that fades out at its foot.