Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@reelkit/react-lightbox

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reelkit/react-lightbox

Full-screen image and video gallery lightbox for React with touch gestures, transitions, and render props

Source
npmnpm
Version
0.1.2
Version published
Weekly downloads
93
304.35%
Maintainers
1
Weekly downloads
 
Created
Source

@reelkit/react-lightbox

npm Bundle size Star on GitHub

Full-screen image gallery lightbox for React. Touch gestures, keyboard navigation, fullscreen API, transition effects, and render props for full customization.

Installation

npm install @reelkit/react-lightbox @reelkit/react lucide-react

Quick Start

import { useState } from 'react';
import { LightboxOverlay, type LightboxItem } from '@reelkit/react-lightbox';
import '@reelkit/react-lightbox/styles.css';

const images: LightboxItem[] = [
  {
    src: 'https://example.com/image1.jpg',
    title: 'Sunset',
    description: 'Beautiful sunset over the ocean',
  },
  {
    src: 'https://example.com/image2.jpg',
    title: 'Mountains',
  },
];

function App() {
  const [index, setIndex] = useState<number | null>(null);

  return (
    <>
      {images.map((img, i) => (
        <img key={i} src={img.src} onClick={() => setIndex(i)} />
      ))}
      <LightboxOverlay
        isOpen={index !== null}
        images={images}
        initialIndex={index ?? 0}
        onClose={() => setIndex(null)}
      />
    </>
  );
}

Features

  • Touch gestures — swipe to navigate, swipe up to close
  • Keyboard navigation — arrow keys, Escape
  • Fullscreen — cross-browser Fullscreen API
  • Transitions — slide, fade, and zoom-in effects
  • Image preloading — adjacent images prefetched
  • Video slides (opt-in) — tree-shakeable video support via useVideoSlideRenderer
  • Counter — "1 / 10" indicator
  • Info overlay — title and description with gradient
  • Render props — renderControls, renderNavigation, renderInfo, renderSlide for full customization
  • Sub-components — CloseButton, Counter, FullscreenButton, SoundButton for composing custom controls

API Reference

LightboxOverlay Props

PropTypeDefaultDescription
isOpenbooleanrequiredControls lightbox visibility
imagesLightboxItem[]requiredArray of images to display
initialIndexnumber0Starting image index
transitionTransitionType'slide'Transition animation type
apiRefMutableRefObject<ReelApi>-Ref to access Reel API
renderControls(props) => ReactNode-Custom controls
renderNavigation(props) => ReactNode-Custom navigation arrows
renderInfo(props) => ReactNode-Custom info overlay
renderSlide(item, index, size, isActive) => ReactNode | null-Custom slide rendering

Callbacks

PropTypeDescription
onClose() => voidCalled when lightbox closes
onSlideChange(index: number) => voidCalled after slide change

Reel Props (proxied)

PropTypeDefaultDescription
loopbooleanfalseEnable infinite loop
useNavKeysbooleantrueEnable keyboard navigation
enableWheelbooleantrueEnable mouse wheel
wheelDebounceMsnumber200Wheel debounce (ms)
transitionDurationnumber300Animation duration (ms)
swipeDistanceFactornumber0.12Swipe threshold (0-1)

Types

interface LightboxItem {
  src: string;
  type?: 'image' | 'video'; // defaults to 'image'
  poster?: string; // thumbnail for video items
  title?: string;
  description?: string;
  width?: number;
  height?: number;
}

type TransitionType = 'slide' | 'fade' | 'zoom-in';

Video Slides (Opt-in)

Video support is tree-shakeable — image-only usage pays zero extra bundle cost. Import useVideoSlideRenderer and wire it into LightboxOverlay to enable video slides.

import {
  LightboxOverlay,
  Counter,
  CloseButton,
  SoundButton,
  useVideoSlideRenderer,
  type LightboxItem,
} from '@reelkit/react-lightbox';
import '@reelkit/react-lightbox/styles.css';

const items: LightboxItem[] = [
  { src: '/photo.jpg', title: 'Photo' },
  {
    src: '/clip.mp4',
    type: 'video',
    poster: '/clip-thumb.jpg',
    title: 'Video Clip',
  },
];

function Gallery() {
  const [index, setIndex] = useState<number | null>(null);
  const isOpen = index !== null;
  const { renderSlide, isMuted, onToggleMute, hasVideo } =
    useVideoSlideRenderer(items, isOpen);

  return (
    <>
      {/* thumbnails… */}
      <LightboxOverlay
        isOpen={isOpen}
        images={items}
        initialIndex={index ?? 0}
        onClose={() => setIndex(null)}
        renderSlide={renderSlide}
        renderControls={({ onClose, currentIndex, count }) => (
          <>
            <div className="rk-lightbox-controls-left">
              <Counter currentIndex={currentIndex} count={count} />
              {hasVideo && (
                <SoundButton isMuted={isMuted} onToggle={onToggleMute} />
              )}
            </div>
            <CloseButton onClick={onClose} />
          </>
        )}
      />
    </>
  );
}

useVideoSlideRenderer

function useVideoSlideRenderer(
  items: LightboxItem[],
  isOpen?: boolean,
): {
  renderSlide: (item, index, size, isActive) => ReactNode | null;
  isMuted: boolean; // current mute state (default: true)
  onToggleMute: () => void;
  hasVideo: boolean; // true if items contain at least one video
};

Pass isOpen to reset muted state when the lightbox closes (enables autoplay on reopen).

SoundButton

PropTypeDescription
isMutedbooleanCurrent mute state
onToggle() => voidToggle callback
classNamestringCSS class (default: rk-lightbox-btn)
styleCSSPropertiesInline styles

Keyboard Shortcuts

KeyAction
ArrowLeftPrevious image
ArrowRightNext image
EscapeClose lightbox (or exit fullscreen)

CSS Classes

All UI elements use CSS classes prefixed with rk-lightbox- that can be overridden:

ClassDescription
.rk-lightbox-containerRoot container
.rk-lightbox-closeClose button
.rk-lightbox-navNavigation arrows
.rk-lightbox-nav-prevPrevious arrow
.rk-lightbox-nav-nextNext arrow
.rk-lightbox-counterImage counter
.rk-lightbox-btnControl buttons
.rk-lightbox-infoTitle/description container
.rk-lightbox-titleImage title
.rk-lightbox-descriptionImage description
.rk-lightbox-slideSlide container
.rk-lightbox-imgImage element
.rk-lightbox-video-containerVideo slide wrapper
.rk-lightbox-video-elementVideo element
.rk-lightbox-video-posterVideo poster image
.rk-lightbox-video-loaderVideo loading indicator

Documentation

Full documentation, interactive demos, and customization examples at reelkit.dev/docs/lightbox.

License

MIT

Keywords

react

FAQs

Package last updated on 13 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts