Duolith docs

ImageViewer

One image full screen to look at closely, with pinch, wheel and double-tap zoom, panning, and Escape or a swipe down to close.

Stability: experimental

Props

PropTypeDefaultMeans
srcstringThe image address; shown at once when an Image already decoded it.
altstringWhat the image shows: the dialog's name and its caption.
openbooleanbindable(false)Whether the viewer is showing. Bind it with bind:open={name}; closing sets it to false.

States

StateLooks like
openThe canvas colour over the whole screen, fading in over 160 ms (none with reduced motion), the caption and a close button at the top.
zoomedThe image from 1x to 4x around the fingers or pointer; dragging pans it, never showing a gap at an edge.
swipingNot zoomed, the image follows a drag down; let go past 96 points to close, or it springs back.

Accessibility

roledialog named by alt; aria-modal while open
nameThe alt prop.
focusOpening moves focus to the close button; Tab and Shift+Tab stay inside; closing returns focus to where it was, such as the Image that opened it. It is a dialog on the shared overlay layer (decision 0034), which also makes the page behind it inert and still; written inside another overlay, such as a Dialog, it closes with that overlay (its open becomes false) and focus goes back to where it was before the Dialog opened.
keyboardEscape closes. Enter or Space on the close button closes.
notesZoom comes from <image zoomable> (decision 0039); the zoom level is in data-zoom on the image.

Theme tokens

color.canvas color.ink color.raised color.muted space.3 space.4 space.6 radius.full text.label text.caption

Example

<ImageViewer src="/photos/city.svg" alt="A city at dusk" bind:open={viewing} />