← All @molecule/* packages · App templates
@molecule/app-gallery-photoswipeProvider bond · gallery · App (browser) · v1.0.1 · Apache-2.0
Headless gallery state provider for @molecule/app-gallery (PhotoSwipe-compatible interface, no lightbox UI)
npm install @molecule/app-gallery-photoswipenpm · Source on GitHub · Implements @molecule/app-gallery
@molecule/app-gallery-photoswipe is a provider bond on the app (browser) side: it implements the gallery core interface (@molecule/app-gallery) with a concrete vendor or library behind it.
Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.
// REQUIRED — also `import 'photoswipe/style.css'` in your app entry (see @remarks)
import { provider } from '@molecule/app-gallery-photoswipe'
import { setProvider, requireProvider } from '@molecule/app-gallery'
setProvider(provider) // once, at app startup (bonds.ts)
const gallery = requireProvider().createGallery({
items: [{ src: '/photos/1.jpg', width: 1200, height: 800, alt: 'Sunset' }],
zoomable: true,
})
gallery.open(0) // opens the PhotoSwipe lightbox at item 0Works with: @molecule/app-gallery
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
PhotoSwipe v5 gallery provider for @molecule/app-gallery.
Drives the real PhotoSwipe lightbox: open() constructs a PhotoSwipe
instance from the core GalleryItem[] (mapped to PhotoSwipe slides) and calls
.init() to actually display it; close() and navigation delegate to the
live instance. This is a real, rendering provider — not headless state.
// REQUIRED — also `import 'photoswipe/style.css'` in your app entry (see @remarks)
import { provider } from '@molecule/app-gallery-photoswipe'
import { setProvider, requireProvider } from '@molecule/app-gallery'
setProvider(provider) // once, at app startup (bonds.ts)
const gallery = requireProvider().createGallery({
items: [{ src: '/photos/1.jpg', width: 1200, height: 800, alt: 'Sunset' }],
zoomable: true,
})
gallery.open(0) // opens the PhotoSwipe lightbox at item 0
provider
npm install @molecule/app-gallery-photoswipe @molecule/app-gallery photoswipe
PhotoSwipeConfigProvider-specific configuration options.
interface PhotoSwipeConfig {
/** Whether to enable zoom by default. Defaults to `true`. */
zoomable?: boolean
/** Whether to show counter by default. Defaults to `true`. */
showCounter?: boolean
}
createProvider(config)Creates a PhotoSwipe-based gallery provider.
Per-gallery GalleryOptions (zoomable, showCounter) override the
provider-level PhotoSwipeConfig; both default to PhotoSwipe's own defaults.
function createProvider(config?: PhotoSwipeConfig): GalleryProvider
config — Optional provider-level configuration.Returns: A configured GalleryProvider backed by PhotoSwipe v5.
providerDefault PhotoSwipe gallery provider instance.
const provider: GalleryProvider
Implements @molecule/app-gallery interface.
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/app-gallery'
import { provider } from '@molecule/app-gallery-photoswipe'
export function setupGalleryPhotoswipe(): void {
setProvider(provider)
}
Peer dependencies:
@molecule/app-gallery ^1.0.1@molecule/app-gallery
photoswipe
Import PhotoSwipe's stylesheet yourself — this package does not:
import 'photoswipe/style.css' (aka photoswipe/dist/photoswipe.css).
Without it the lightbox opens unstyled/invisible.
Browser-only. open() runs new PhotoSwipe(...).init(), which needs a
live DOM — construct/open galleries in a client-only effect, never during SSR.
open() renders the real lightbox (unlike a headless provider). Each
GalleryItem maps to a PhotoSwipe slide — src, width, height, alt;
thumbnail → msrc (low-res placeholder); caption carried through — opened
at startIndex/the given index. getCurrentIndex() follows PhotoSwipe's own
navigation (arrows/swipe/keyboard) via its change event.
GalleryOptions drive PhotoSwipe: onClose fires on the lightbox close
event; zoomable → PhotoSwipe's zoom button, showCounter → its counter
(per-gallery options override the provider-level PhotoSwipeConfig; both
default on). showThumbnails has no effect — PhotoSwipe core has no thumbnail
strip (it needs a separate plugin).
Wire it with setProvider() from @molecule/app-gallery or
bond('gallery', provider) from @molecule/app-bond — both route through the
shared registry; requireProvider() throws until one has run.
Integration checklist - drive the real UI (live preview, no mocks), adapt each item to this app's actual gallery screen, and check every box off one by one. A box you can't check is an integration bug to fix - not a skip: