Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
Data display

MediaViewport

Inspects application-owned media with bounded zoom, pan, fit and keyboard alternatives.

FrameworksAstro · React · Elements

Registry commandlumen add MediaViewport

InteractionEnhanced runtime

01

See it and copy it

Framework example

Choose Astro, React, or Elements to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroCode target · live preview uses Astro
A landscape illustration with mountains and a lake
Inspect the illustrative landscape100%

Zoom in to inspect details. Drag to pan, or use the pan buttons and arrow keys. Home fits the image.

View MediaViewport code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.
astro
---
import { Image, MediaViewport } from '@santi020k/lumen-astro'
---

<MediaViewport label="Inspect the illustrative landscape" ratio={1.6}>
  <Image alt="A landscape illustration with mountains and a lake" height={600} radius="none" src="/comparison-after.svg" width={960} />
</MediaViewport>
<p>Zoom in to inspect details. Drag to pan, or use the pan buttons and arrow keys. Home fits the image.</p>
Edit MediaViewport in browser
02

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add MediaViewport
lumen add MediaViewport

API reference

Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.

AttributeValuesDefaultDescription
label / labelsstring / Partial<LumenMediaViewportLabels>required / English action labelsNames the preview and localizes visible actions. Elements exposes a labels property.
value / defaultValueLumenMediaViewportValue / Partial<LumenMediaViewportValue>fit at zoom 1Zoom is relative to fit; x and y are bounded fractions (-1 to 1) of the pan extent. React value is controlled; defaultValue initializes local state. Astro value initializes data-zoom, data-pan-x and data-pan-y. Elements value is a reflected property.
maxZoom / rationumber4 / 16:9Zoom limits normalize into 1–16. Preview ratio accepts 0.1–10; invalid ratios fall back to 16:9. Elements uses max-zoom.
onValueChange(value: LumenMediaViewportValue) => void-React callback; Astro and Elements emit ui:media-viewport-change with { zoom, x, y }.
disabled / localeboolean / stringfalse / environment localeDisables gestures and actions; formats visible zoom percentage. Astro actions stay disabled until enhancement.
childrenmedia contentrequiredSupplies an image or noninteractive media view with meaningful alternative text. Loading, caching, retries and editing remain consumer-owned.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Keyboard interactions

Keyboard behavior provided by the Astro UIPrimitives runtime for this component.

KeyAction
+ / -Zoom in or out while the viewport is focused.
Arrow keysPan the zoomed media.
HomeFit the media and reset pan.

Runtime events

CustomEvents dispatched by the Astro UIPrimitives runtime for this component.

EventTargetDetailWhen
ui:media-viewport-changeMediaViewport root{ zoom: number, x: number, y: number }Reports an accepted zoom, pan or fit interaction.

Web docsFull catalog