Skip to content

Lightbox API

API Reference: Engine · Types · Storage · Events · Security · Servers · Placement · This Page · Lens · Embeds · Coordinators · Config Registry

Full-screen overlay carousel for browsing link collections with images, metadata, and embeds.

See also: Cookbook: Lightbox for usage patterns and styling recipes.

Quick start

typescript
import { AlapLightbox, defineAlapLightbox, registerConfig } from 'alap';

registerConfig(myConfig);
defineAlapLightbox();
html
<alap-lightbox query=".bridge">NYC Bridges</alap-lightbox>

AlapLightbox class

Programmatic API for the lightbox renderer.

typescript
const lightbox = new AlapLightbox(config, {
  placement: 'C',
  embedPolicy: 'prompt',
});

Constructor

typescript
new AlapLightbox(config: AlapConfig, options?: AlapLightboxOptions)

Methods

MethodSignatureDescription
openWith()(payload: OpenPayload) => voidOpen with pre-resolved links
close()() => HTMLElement | nullClose overlay, returns the trigger element
setPlacement()(placement: Placement | null) => voidChange viewport placement at runtime
getEngine()() => AlapEngineAccess the underlying engine
destroy()() => voidClose overlay and remove event listeners

Properties

PropertyTypeDescription
isOpenbooleanWhether the lightbox is currently visible
rendererType'lightbox'Renderer type constant (for coordinator)

AlapLightboxOptions

OptionTypeDefaultDescription
selectorstring'.alap'CSS selector for trigger elements
placementPlacementnullViewport placement (compass direction)
embedPolicyEmbedPolicy'prompt''prompt' | 'allow' | 'block'
embedAllowliststring[]all providersOverride default embed provider allowlist

<alap-lightbox> web component

Registration

typescript
import { defineAlapLightbox } from 'alap';

defineAlapLightbox();            // registers as <alap-lightbox>
defineAlapLightbox('my-viewer'); // custom tag name

Safe to call multiple times — subsequent calls are no-ops.

HTML attributes

AttributeDescription
queryAlap expression (e.g. .bridge, @favorites)
configNamed config to use (default: '_default')
placementViewport placement (compass direction)

Methods

MethodDescription
close()Close the lightbox programmatically

ARIA

The web component automatically sets role="button", aria-haspopup="dialog", tabindex="0", and toggles aria-expanded.

CSS custom properties

All properties use the --alap-lightbox- prefix. Override them on :root or on alap-lightbox directly.

Show all custom properties

Overlay

PropertyDefault
--alap-lightbox-z-index10000
--alap-lightbox-overlay-bgrgba(0, 0, 0, 0.85)
--alap-lightbox-overlay-blur4px
--alap-lightbox-fade0.5s

Panel

PropertyDefault
--alap-lightbox-bg#1a1a2e
--alap-lightbox-radius12px
--alap-lightbox-max-width600px
--alap-lightbox-shadow0 24px 80px rgba(0, 0, 0, 0.5)
--alap-lightbox-transition0.25s
--alap-lightbox-body-padding0.75rem 1.5rem 1.5rem

Image

PropertyDefault
--alap-lightbox-image-height350px
--alap-lightbox-image-bg#111

Label

PropertyDefault
--alap-lightbox-label-size1.4rem
--alap-lightbox-label-weight600
--alap-lightbox-label-color#fff

Photo credit

PropertyDefault
--alap-lightbox-credit-size0.75rem
--alap-lightbox-credit-colorrgba(255, 255, 255, 0.4)
--alap-lightbox-credit-link-colorrgba(255, 255, 255, 0.5)
--alap-lightbox-credit-link-hover#fff

Description

PropertyDefault
--alap-lightbox-desc-margin0.5rem 0 0
--alap-lightbox-desc-color#aaa
--alap-lightbox-desc-size0.95rem
--alap-lightbox-desc-line-height1.5

Visit button

PropertyDefault
--alap-lightbox-visit-bg#3a86ff
--alap-lightbox-visit-color#fff
--alap-lightbox-visit-radius6px
--alap-lightbox-visit-size0.9rem
--alap-lightbox-visit-weight500
--alap-lightbox-visit-padding0.5rem 1.25rem
--alap-lightbox-visit-bg-hover#2d6fdb
--alap-lightbox-visit-margin1rem auto 0

Close button (X)

PropertyDefault
--alap-lightbox-close-x-color#fff
--alap-lightbox-close-x-size2rem
--alap-lightbox-close-x-opacity0.7

Close button (text)

PropertyDefault
--alap-lightbox-close-margin0.5rem auto 0
--alap-lightbox-close-bgrgba(255, 255, 255, 0.1)
--alap-lightbox-close-color#b8c4e8
--alap-lightbox-close-bg-hoverrgba(255, 255, 255, 0.15)
--alap-lightbox-close-color-hover#fff

Counter

PropertyDefault
--alap-lightbox-counter-margin1rem
--alap-lightbox-counter-color#666
--alap-lightbox-counter-size0.85rem
--alap-lightbox-counter-hover-color#aac4f0

Navigation

PropertyDefault
--alap-lightbox-nav-bgrgba(255, 255, 255, 0.1)
--alap-lightbox-nav-color#fff
--alap-lightbox-nav-icon-size2rem
--alap-lightbox-nav-btn-size48px
--alap-lightbox-nav-bg-hoverrgba(255, 255, 255, 0.2)
--alap-lightbox-nav-offsetcalc(50% - 340px)

Set navigator popup

PropertyDefault
--alap-lightbox-setnav-bg#1e1e3a
--alap-lightbox-setnav-borderrgba(255, 255, 255, 0.1)
--alap-lightbox-setnav-radius8px
--alap-lightbox-setnav-shadow0 8px 32px rgba(0, 0, 0, 0.4)
--alap-lightbox-setnav-min-width220px
--alap-lightbox-setnav-max-width320px
--alap-lightbox-setnav-max-height240px
--alap-lightbox-setnav-item-padding0.4rem 0.75rem
--alap-lightbox-setnav-item-color#d0d7e5
--alap-lightbox-setnav-item-size0.85rem
--alap-lightbox-setnav-item-hover-bgrgba(255, 255, 255, 0.1)
--alap-lightbox-setnav-item-hover-color#fff
--alap-lightbox-setnav-item-active-bgrgba(58, 134, 255, 0.2)
--alap-lightbox-setnav-item-active-color#88bbff
--alap-lightbox-setnav-item-active-weight600
--alap-lightbox-setnav-filter-padding0.5rem 0.75rem
--alap-lightbox-setnav-filter-bgrgba(255, 255, 255, 0.05)
--alap-lightbox-setnav-filter-color#fff
--alap-lightbox-setnav-filter-size0.8rem

::part() selectors

Style lightbox internals from outside the shadow DOM:

css
alap-lightbox::part(panel) {
  background: #2a2a4e;
  max-width: 800px;
}

alap-lightbox::part(visit) {
  background: coral;
}
Show all part names
PartElement
overlayMain overlay backdrop
panelContent card
close-xTop-right close button
image-wrapImage container
imageImage element
bodyText content area
label-rowTitle + credit row
labelTitle (h2)
creditPhoto credit attribution
descriptionDescription paragraph
visitVisit link button
close-btnClose button (text)
counter-wrapCounter container
counterCounter text (e.g. "1 of 5")
setnavSet navigator popup
setnav-filterFilter input in set navigator
nav-prevPrevious navigation zone
nav-nextNext navigation zone
zoom-overlayImage zoom overlay