Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-zoom-pan>

@methane-ui/ui~6.8 KB brotli (cold + Lit)~1.4 KB marginal

Accessible zoom and pan viewport with toolbar buttons, mouse wheel zoom, pointer pan, keyboard pan/zoom, and adopted CSSStyleSheet transforms.

When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-zoom-pan> (@methane-ui/ui)
Zoomable DiagramUse +/- controls, scroll wheel, or drag to pan.
Ready · interact with <mth-zoom-pan>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/zoom-pan"></script>
<mth-zoom-pan scale="1" min-scale="1">Example</mth-zoom-pan>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
scalescalenumber1Current zoom multiplier.
minScalemin-scalenumber1Minimum allowed zoom scale.
maxScalemax-scalenumber4Maximum allowed zoom scale.
stepstepnumber0.25Zoom scale increment per control/wheel step.
panXpan-xnumber0Horizontal pan offset in pixels.
panYpan-ynumber0Vertical pan offset in pixels.
labellabelstring""Accessible region label.
showControlsshow-controlsbooleantrueDisplays zoom-in, zoom-out, and reset toolbar buttons.

Events

EventDetail TypeDescription
mth-change{ scale: number; panX: number; panY: number }Fired when scale or pan coordinates change.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
+ / =bothviewport focusedzooms in by step up to maxScale
-bothviewport focusedzooms out by step down to minScale
0bothviewport focusedresets zoom and pan offset
Arrow keysbothzoomed and viewport focusedpans viewport offset (RTL-aware)

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 4 APG keyboard transitions across LTR/RTL.mth-zoom-pan.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(zoomed).Conformance suite
i18nRoutes 4 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test