Media viewer
ProA full-screen viewer for a set of photos: swipe between them, zoom, and read each caption and position. Not an M3 component (@windmorph/react-pro).
import { MediaViewer } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Purpose
A media viewer shows a set of photos full screen: it opens on the photo that was tapped, moves between them, zooms, and shows each one's caption and position ("Photo 2 of 7"). Use it wherever photos are shown as thumbnails: posts, listings, profiles and catalogues. It is not an M3 component, so it comes from @windmorph/react-pro.
Control it with open and index (or leave them uncontrolled with defaultOpen and defaultIndex), name it with aria-label, and pass every word through labels from your translations. actions adds controls to the top bar, such as a menu with "Open post". Pass the thumbnail that was tapped as origin, and the viewer grows out of it and shrinks back into it, the M3 container transform; keep it on the open photo's thumbnail as the viewer moves, so it closes into the right one.
Gestures
- Swipe or drag sideways to move between photos: the photo follows the pointer, then settles on the fast spatial spring. A quick flick is enough, and past the first or last photo the drag resists.
- Double-tap or double-click to zoom to 2×; pinch, or use Ctrl or ⌘ with the wheel (one step a notch; a trackpad pinch follows smoothly), for up to 4×. Dragging a zoomed photo pans it, and the wheel pans it too.
- Swipe down on touch to close.
- The two photos on each side are loaded ahead. Each photo needs its
widthandheight(both required), so it's laid out before it loads, and asrcSetfor sharp zooming on large screens.
When not to use
To browse items inline on the page, use a Carousel; to frame a photo before upload, an Image crop.
See also
- Carousel: A scrollable row of items that resize along keylines: multi-browse, uncontained, multi-aspect, hero or full-screen.
- Dialog: A modal surface for a focused task or a decision, with a title, content and actions, or full screen on compact windows.
- Image crop: Frames a photo before upload: drag, pinch or zoom it behind a fixed frame, and get the crop in the original pixels. Not an M3 component (@windmorph/react-pro).