Componentmedia1.59 KB gzipZero dependencies

Lightbox

Fullscreen media viewer with film frame edges and image paging.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add lightbox

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { Lightbox } from "@/components/ui/lightbox"; <Lightbox open={open} onOpenChange={setOpen} images={[{ src: "/pass.png" }]} />

Source code

lightbox.tsx + 2 helpers

Zero third-party dependencies (3 local files shown in tabs below).

tsxlightbox.tsx153 lines
"use client"; import * as React from "react";import { getFocusable, lockBodyScroll, registerEscapeLayer, trapFocus } from "./lib/focus-trap";import { cn } from "./lib/utils"; export interface LightboxImage {  src: string;  alt?: string;  title?: string;} export interface LightboxProps extends React.HTMLAttributes<HTMLElement> {  open: boolean;  onOpenChange: (open: boolean) => void;  images: LightboxImage[];  initialIndex?: number;  className?: string;

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { Lightbox } from "@/components/ui/lightbox"; <Lightbox />
PropTypeDescription
openbooleanControlled open visibility state.
onOpenChange(open: boolean) => voidCallback invoked on open change.
imagesLightboxImage[]Configures images. (Default: [])
initialIndexnumberConfigures initial index. (Default: 0)
classNamestringOptional Tailwind or custom CSS classes merged with component styles.