Clarity V2.0.1By Nivoda
ComponentsOverlays

Lightbox

Full-screen media viewer for images and 360° video. System-wide — not PDP-specific. Any component in the system can use it.

Props

PropTypeDefaultDescription
mediaProductMedia[]requiredImages and/or a 360° video to display
initialIndexnumber0Which item to show first
onClose() => voidrequiredCalled when user closes the lightbox

Usage

const [lightboxIndex, setLightboxIndex] = useState<number | null>(null)

<button onClick={() => setLightboxIndex(0)}>Open</button>

{lightboxIndex !== null && (
  <Lightbox
    media={media}
    initialIndex={lightboxIndex}
    onClose={() => setLightboxIndex(null)}
  />
)}

Keyboard navigation

  • Escape — close
  • ArrowLeft / ArrowRight — previous / next item

360° video

When a video360 item is active, a scrub bar is always visible (desktop and mobile). Drag the thumb left/right to rotate the video.

Best practices

Do: Render Lightbox conditionally ({idx !== null && <Lightbox ... />}) and control open/close state in the consumer. The consumer owns whether the lightbox is open.

Don't: Keep Lightbox always mounted — it uses fixed positioning and will block page interactions when open.

Quality checklist

  • role="dialog" + aria-modal="true" on the overlay
  • Keyboard: Escape closes, ArrowLeft/ArrowRight navigate
  • Close and nav buttons have aria-label
  • Scrub bar always visible for 360° items (no hover dependency inside Lightbox)
  • Tokens only — no hardcoded colours

On this page