Click an image. Use ← → to browse and Esc to close.
Installation
$ pnpm dlx shadcn@latest add @synccn/lightboxFirst time in this project? Connect synccn with one command.
Usage
import { Lightbox } from "@/components/ui/lightbox";<Lightbox items={photos} />API reference
Generated from the component's TypeScript types, so it always matches the code.
Lightbox
Thumbnail grid that opens a full-screen viewer with arrows, swipe, keyboard (←, →, Esc) and a thumbnail strip. items: [{ id, thumb: ReactNode, full: ReactNode, caption? }]
PropTypeDescription
- itemsrequired
LightboxItem[]Images.
- columns
2 | 3 | 4Default
3Thumbnail columns.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for ChevronLeft, ChevronRight, X
Keyboard
- ←or→Previous or next image
- EscClose
- TabMove focus; it stays inside while open
Accessibility
- Swipe left or right on touch screens. Thumbnails mark the current image with aria-current.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: dialog
- ARIA attributes: aria-current, aria-label, aria-modal
- Keys handled: ArrowLeft, ArrowRight, Escape
- Keeps keyboard focus inside while open, and returns it when closed
- Stops the page behind from scrolling while open
- Shows a visible focus ring for keyboard users
More overlays
DialogModal with focus trap, scroll lock and Escape to close.SheetPanel that slides in from the left, right or bottom.Dropdown MenuActions, checkboxes, labels and shortcuts with arrow-key navigation.Context MenuRight-click menu that also opens on long-press.PopoverFloating panel anchored to a trigger.TooltipLabel on hover and focus, on any side.