Atrium // Components
Lightbox
A lightbox component for displaying images in a full-screen overlay with backdrop blur and smooth transitions.
A lightbox component that displays images in an immersive full-screen overlay. When clicked, the thumbnail expands to show the full-resolution image with a darkened backdrop, providing focus on the content while maintaining visual context of the underlying page.
<script setup lang="ts">
import "@atrium-ui/elements/lightbox";
import Button from "./Button.vue";
import Icon from "./Icon.vue";
</script>
<template>
<a-lightbox>
<button
slot="trigger"
type="button"
class="m-0 block cursor-pointer bg-transparent rounded-md overflow-hidden"
>
<img
class="max-w-[200px] bg-zinc-400 object-cover"
src="https://picsum.photos/id/12/320/180"
alt=""
/>
</button>
<div
slot="content"
class="relative flex max-h-[95vh] max-w-[95vw] items-center justify-center [&_img]:max-h-[95vh] [&_img]:max-w-[95vw] [&_img]:object-contain"
>
<slot />
</div>
<div slot="close" class="fixed top-3 right-3 z-[2] text-2xl lg:top-5 lg:right-5 lg:text-3xl">
<Button label="close" variant="ghost">
<Icon name="close" />
</Button>
</div>
</a-lightbox>
</template> Examples
Single Image
Click the image to open it in the lightbox. The lightbox will display the full-resolution image with a backdrop blur effect. Click the close button or press Escape to exit.
Guidelines
- Use for Focus: Use lightbox when you want users to focus on visual content without leaving the current page context.
Accessibility
- Keyboard Navigation: Pressing the Escape key closes the lightbox.
- Focus Management: Focus is trapped within the lightbox when open, and returns to the trigger element when closed.
- Screen Readers: Images should have descriptive alt text to convey content to screen reader users.
- Visual Feedback: The backdrop blur provides clear visual separation between the lightbox and page content.
- Close Button: A clearly labeled close button is always visible and accessible.