Skip to content

Lens API

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

Detail panel overlay for inspecting individual links with full metadata, tags, images, and embeds.

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

Quick start

typescript
import { AlapLens, defineAlapLens, registerConfig } from 'alap';

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

AlapLens class

Programmatic API for the lens renderer.

typescript
const lens = new AlapLens(config, {
  transition: 'fade',
  copyable: true,
  embedPolicy: 'prompt',
});

Constructor

typescript
new AlapLens(config: AlapConfig, options?: AlapLensOptions)

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 lens is currently visible
rendererType'lens'Renderer type constant (for coordinator)

AlapLensOptions

OptionTypeDefaultDescription
selectorstring'.alap'CSS selector for trigger elements
visitLabelstring'Visit →'Label for the visit/navigate button
closeLabelstring'Close'Label for the close button
metaLabelsRecord<string, string>{}Custom display names for meta keys
copyablebooleantrueShow copy-to-clipboard on panel hover
panelCloseButtonbooleanfalseShow a Close button in the actions row
transition'fade' | 'resize' | 'none''fade'Navigation transition between items
tagSwitchTooltipnumber3000Duration (ms) of tag-switch tooltip. 0 to disable
placementPlacement'C'Viewport placement (compass direction)
embedPolicyEmbedPolicy'prompt''prompt' | 'allow' | 'block'
embedAllowliststring[]all providersOverride default embed provider allowlist

Transition modes

ModeBehavior
'fade'Opacity crossfade between items. No reflow.
'resize'Animated height change. Smooth panel resize.
'none'Instant swap, no animation.

<alap-lens> web component

Registration

typescript
import { defineAlapLens } from 'alap';

defineAlapLens();              // registers as <alap-lens>
defineAlapLens('my-detail');   // custom tag name

HTML attributes

AttributeDescription
queryAlap expression (e.g. .bridge, @favorites)
configNamed config to use (default: '_default')
placementViewport placement (compass direction)
transition'fade' | 'resize' | 'none'
copyableShow copy button ('true' or 'false')
panel-close-buttonShow close button in actions row
tag-switch-tooltipTooltip duration in ms
visit-labelVisit button label
close-labelClose button label
meta-labelsJSON string with custom meta field labels

Methods

MethodDescription
close()Close the lens 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-lens- prefix.

Show all custom properties

Panel

PropertyDefault
--alap-lens-bg#1a1a2e
--alap-lens-radius12px
--alap-lens-shadow0 24px 80px rgba(0, 0, 0, 0.5)
--alap-lens-max-width520px
--alap-lens-padding1.5rem

Overlay

PropertyDefault
--alap-lens-overlay-bgrgba(0, 0, 0, 0.85)
--alap-lens-overlay-blur4px
--alap-lens-overlay-padding2rem
--alap-lens-z-index10000

Label

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

Description

PropertyDefault
--alap-lens-desc-color#aaa
--alap-lens-desc-size0.95rem
--alap-lens-desc-line-height1.5

Tags

PropertyDefault
--alap-lens-tag-bgrgba(255, 255, 255, 0.1)
--alap-lens-tag-color#aac4f0
--alap-lens-tag-radius12px
--alap-lens-tag-size0.8rem
--alap-lens-tag-padding0.15rem 0.6rem
--alap-lens-tag-gap0.35rem

Image

PropertyDefault
--alap-lens-image-max-height280px
--alap-lens-image-portrait-max-height420px
--alap-lens-image-radius8px

Meta fields

PropertyDefault
--alap-lens-meta-key-color#7888b8
--alap-lens-meta-key-size0.85rem
--alap-lens-meta-key-width100px
--alap-lens-meta-value-color#d0d7e5
--alap-lens-meta-value-size0.9rem
--alap-lens-meta-chip-bgrgba(255, 255, 255, 0.08)
--alap-lens-meta-chip-color#aac4f0
--alap-lens-meta-link-color#88bbff
--alap-lens-meta-link-hover#ffd666
--alap-lens-meta-muted-color#5a6a9a
--alap-lens-meta-row-gap1rem
--alap-lens-meta-row-padding0.3rem 0

Visit button

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

Close buttons

PropertyDefault
--alap-lens-close-bgrgba(255, 255, 255, 0.1)
--alap-lens-close-bg-hoverrgba(255, 255, 255, 0.15)
--alap-lens-close-color#b8c4e8
--alap-lens-close-color-hover#fff
--alap-lens-close-x-color#fff
--alap-lens-close-x-size2rem
--alap-lens-close-x-opacity0.7

Copy button

PropertyDefault
--alap-lens-copy-colorrgba(255, 255, 255, 0.3)
--alap-lens-copy-color-hoverrgba(255, 255, 255, 0.7)
--alap-lens-copy-done-color#4ade80
--alap-lens-copy-size1.2rem

Navigation

PropertyDefault
--alap-lens-nav-bgrgba(255, 255, 255, 0.1)
--alap-lens-nav-bg-hoverrgba(255, 255, 255, 0.2)
--alap-lens-nav-color#fff
--alap-lens-nav-btn-size36px
--alap-lens-nav-icon-size1.5rem
--alap-lens-counter-color#666
--alap-lens-counter-size0.85rem
--alap-lens-counter-hover-color#aac4f0
--alap-lens-counter-min-width7em

Drawer

PropertyDefault
--alap-lens-drawer-toggle-colorrgba(255, 255, 255, 0.4)
--alap-lens-drawer-toggle-hoverrgba(255, 255, 255, 0.8)
--alap-lens-drawer-scrollbar-colorrgba(255, 255, 255, 0.2)

Transitions

PropertyDefault
--alap-lens-transition0.25s
--alap-lens-fade0.5s
--alap-lens-resize-transition0.35s

::part() selectors

css
alap-lens::part(panel) {
  background: #2a2a4e;
}

alap-lens::part(tags) {
  gap: 0.5rem;
}
Show all part names
PartElement
overlayMain overlay backdrop
close-xClose button (top right)
panelMain content panel
image-wrapImage container
imageImage element
drawerScrollable details container
drawer-handleDrawer expand/collapse handle
drawer-toggleDrawer toggle icon
title-rowLabel + photo credit row
labelItem title/label
creditPhoto credit attribution
tagsTag container
descriptionItem description
metaMetadata section (dl)
separatorSeparator line before meta
actionsAction buttons container
visitVisit/navigate link
close-btnClose button in actions
navNavigation buttons container
nav-prevPrevious button
nav-nextNext button
counter-wrapCounter wrapper
counterItem counter (e.g. "1 of 5")
setnavSet navigator popup
setnav-filterSet navigator filter input
zoom-overlayImage zoom overlay