A photo grid that opens into a viewer. The photo zooms out of its tile and returns to it.
FreeWeb and MobileMotion
Preview
npx shadcn add @fetaui/lightbox-gridPlayground
Field trip
Grid
Field trip
Open
Lake shore, early morning
Dismissing
Lake shore, early morning
Start in
Icons animation
Motion
Installation
Terminal· bash
npx shadcn add @fetaui/lightbox-grid
Accessibility
- The viewer is a dialog that traps focus and starts on Close.
- Closing returns focus to the photo that opened it.
- The caption is announced as you page.
- Each tile and thumbnail is a button named by its photo.
Motion
- The photo moves from its tile to the viewer with a 350 ms spring, as a transform only.
- The rest of the viewer fades in over 150 ms.
- Dismiss shrinks to 90% and fades to 60%, then returns to the tile, 300 ms in all.
- On touch screens, swipe down past 80 px to close.
- With reduced motion, the viewer swaps in place.
Responsive behavior
- 576 px on Web with a 337 px viewer.
- 358 px on Mobile with a 261 px viewer.
- The card is taller while the viewer is open, 491 px on Web and 423 px on Mobile.
Performance
- The viewer mounts only while it is open. The grid is removed from the DOM meanwhile.
- Opening and closing use transforms on the frame only, measured once from the tile.
- Swipe to close runs only on coarse pointers, checked once on mount.
Note for AI
Give your coding assistant the Markdown reference instead of screenshots.
- Import LightboxGrid from @/components/fetaui/lightbox-grid. Without photos it shows six stand-ins.
- Each photo needs alt, caption and meta, and caption must be unique. src is the image, and art picks a stand-in.
- Images use a plain img tag with no lazy loading, so pass sized files.
- The viewer is a dialog inside the card, not a page overlay. Focus returns to the tile on close. Composes Card and Icon Button.
Related
Card StackComponentA fanned stack of prints. Drag the top card to skip, or open it for specs and Add to cart.Aspect RatioComponentHolds an image or video at a fixed ratio, so layouts never jump while media loads.CarouselComponentA rail of tall cards. The centred card grows to 106% and shows its price.DialogComponentA window over the page for one focused task, with the page behind made inert. On Mobile it is a bottom sheet.AttachmentComponentA file on its way up or already there, with a drop zone and an upload queue.