DOCS
v0.4

Components / Lightbox

Lightbox

Fullscreen image viewer with prev/next navigation, keyboard control, focus trap, and scroll lock. Pairs with cg-image-gallery. Set the `images` property in JS.

overlaysv0.8.0

Playground

Examples

Open a gallery
Open lightbox
<cg-button variant="primary" onclick="this.nextElementSibling.open=true">Open lightbox</cg-button><cg-lightbox></cg-lightbox>

Import

import { CgLightbox } from '@cognivo/components';
// Or tree-shake: import '@cognivo/components/cg-lightbox';

Per-component imports ship only that component (~8 kB gzip).

API Reference

PropTypeDefaultDescription
openbooleanfalseControls visibility
indexnumber0Current image index
closablebooleantrueShow close button + allow Escape/backdrop close

Events

EventDetailDescription
cg-lightbox-openvoidOpened
cg-lightbox-closevoidClosed
cg-lightbox-change{index: number}Navigated to another image