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

<mth-lightbox>

@methane-ui/ui~9.0 KB brotli (cold + Lit)~2.6 KB marginal

Modal media lightbox wrapping <dialog> with OverlayController, FocusTrapController, sanitized image URLs, zoom toggle, and keyboard gallery navigation.

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-lightbox> (@methane-ui/ui)
Open Media Lightbox (3 Slides)
Ready · interact with <mth-lightbox>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/lightbox"></script>
<mth-lightbox index="0" loop>Example</mth-lightbox>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
openopenbooleanfalseControls whether the lightbox modal is open.
indexindexnumber0Zero-based index of the currently active media item.
looploopbooleantrueWraps navigation from last item to first and vice versa.
closableclosablebooleantrueRenders the close button inside the toolbar.
zoomablezoomablebooleantrueAllows toggling zoomed image presentation.
labellabelstring""Accessible dialog title announced to assistive technologies.
items—ReadonlyArray<unknown>—Array of media entries { src, alt?, caption?, title? }.

Events

EventDetail TypeDescription
mth-openundefinedCancelable event fired before opening the lightbox.
mth-after-openundefinedFired after the lightbox finishes opening.
mth-close{ reason: string }Cancelable event fired before closing the lightbox.
mth-after-closeundefinedFired after the lightbox closes.
mth-change{ index: number; item: unknown | null }Fired when the active item index changes.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
EscapebothopenCloses the lightbox and restores focus to trigger.
ArrowRightbothopenMoves to the next lightbox item.
ArrowLeftbothopenMoves to the previous lightbox item.

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusFocus ownership matches focusModel="none".lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 3 APG keyboard transitions across LTR/RTL.mth-lightbox.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(open), :state(zoomed).Conformance suite
i18nRoutes 8 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test