← All Components
<mth-lightbox>
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
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>import '@methane-ui/ui/lightbox';
import '@methane-ui/react';
export function Example() {
return <mth-lightbox index="0" loop>Example</mth-lightbox>;
}<script setup lang="ts">
import '@methane-ui/ui/lightbox';
</script>
<template>
<mth-lightbox index="0" loop>Example</mth-lightbox>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/lightbox';
import { MthLightboxDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthLightboxDirective],
template: `<mth-lightbox index="0" loop>Example</mth-lightbox>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/lightbox';
import MthLightbox from '@methane-ui/svelte/MthLightbox.svelte';
</script>
<MthLightbox index="0" loop>Example</MthLightbox>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
open | open | boolean | false | Controls whether the lightbox modal is open. |
index | index | number | 0 | Zero-based index of the currently active media item. |
loop | loop | boolean | true | Wraps navigation from last item to first and vice versa. |
closable | closable | boolean | true | Renders the close button inside the toolbar. |
zoomable | zoomable | boolean | true | Allows toggling zoomed image presentation. |
label | label | string | "" | Accessible dialog title announced to assistive technologies. |
items | — | ReadonlyArray<unknown> | — | Array of media entries { src, alt?, caption?, title? }. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-open | undefined | Cancelable event fired before opening the lightbox. |
mth-after-open | undefined | Fired after the lightbox finishes opening. |
mth-close | { reason: string } | Cancelable event fired before closing the lightbox. |
mth-after-close | undefined | Fired after the lightbox closes. |
mth-change | { index: number; item: unknown | null } | Fired when the active item index changes. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Escape | both | open | Closes the lightbox and restores focus to trigger. |
| ArrowRight | both | open | Moves to the next lightbox item. |
| ArrowLeft | both | open | Moves to the previous lightbox item. |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="none". | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 3 APG keyboard transitions across LTR/RTL. | mth-lightbox.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(open), :state(zoomed). | Conformance suite |
| i18n | Routes 8 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |