Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Inline Expansion Thumbnail Grid Block for React

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.

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

An inline-expansion grid for React with Base UI. A start-aligned header sits over sixteen drawn thumbnails on shared hairlines that run rail to rail: eight across from md, four on a phone. Choose a thumbnail and a preview band opens right under its row, across the whole grid and marked with + marks on its corners: the picture whole at its own ratio, its title, source and size, Previous, Next and Close. The thumbnail carries aria-expanded and aria-controls, the band sits in the DOM straight after it, Escape or Close shuts the band and focus returns to the thumbnail. Closed, the band rests at the foot as an empty tray, so the grid never changes height. The pictures are drawn in the theme's greys. It's built from Guides and Button. For search results, stock libraries and any grid where a detail should open in place rather than in a dialog.

FAQ

Where does the band open, and why doesn't the page move?

Under the chosen row. The band is a full-width grid item placed on the row below the thumbnail; the later thumbnails flow into the rows after it. When nothing is open the same band rests after the last row as an empty tray, so the block is always the same height: opening a picture moves the rows below it down by exactly the tray's height.

What happens to focus?

The band is in the DOM straight after the thumbnail that opened it, so Tab goes into it next. Previous and Next keep focus on the button you pressed, even though the band is rebuilt in a new place when the next picture is in another row. Close and Escape return focus to the thumbnail.

Which keys work?

Tab visits every thumbnail, Enter or Space opens or closes one, Escape closes the band while focus is inside the block, and Previous and Next wrap round at the ends.

How do I use my own photographs?

The drawn pictures are one Scene component. Where the code comment says so, replace it with an <img> (object-cover in a box of the picture's own ratio) and give each entry a src. Keep each entry's ratio the photograph's own so the layout doesn't change. The preview shows the picture whole at its own ratio and the grid crops it square, so keep each entry's ratio the photograph's own.

Why not a dialog?

A dialog hides the grid. Here the picture opens in context, next to the pictures you are choosing between, and nothing is trapped: the rest of the page stays reachable. For a full-screen viewer, see the lightbox.

How does it fit on a phone?

Four thumbnails across; the band opens under the tapped row with the picture on top, then the title and source, then Previous, Next and the position. The tray keeps one height, so opening never scrolls the page.

  • 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

    Lightbox Gallery

    Stage and thumbnails

    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.

  • Pro

    Twelve drawn potted plants on shared hairlines where choosing one grows its tile to two cells wide and two tall while the others flow around it, one open at a time, with Escape or a button to put it back and a grid that never changes 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

    Featured Hero Gallery

    Masonry and mosaic

    A boat-charter gallery on one hairline grid: a featured picture two cells wide and tall beside four small ones, and choosing a small picture swaps it with the featured one in place.

  • Pro

    Six drawn frames in cells of their own, each a link with a hover card of camera, lens, aperture, shutter speed and ISO that opens on hover and on keyboard focus, and prints the same settings in the caption on a touch screen.