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

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

@reelkit/react-lightbox

npm Bundle size Coverage Star on GitHub

Image gallery lightbox for React — opens full-screen with swipe navigation, keyboard controls, and transition effects. Everything is replaceable via render props if the defaults don't fit. ~3.2 kB gzip.

Live Demo

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 — tree-shakable slideTransition, flipTransition, lightboxFadeTransition, lightboxZoomTransition (import only what you use)
  • 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 to override any part of the UI
  • 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
transitionFnTransitionTransformFnslideTransitionSlide transition fn (built-in or custom)
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
enableNavKeysbooleantrueEnable 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;
}

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-overlayRoot 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-spinnerDefault loading spinner
.rk-lightbox-img-errorError state container
.rk-lightbox-swipe-hintMobile swipe hint chip

Theming via CSS custom properties

Every visual value is exposed as a --rk-lightbox-* custom property with a sensible default. Override at :root (or any ancestor of .rk-lightbox-overlay) to retheme without touching component source — see the Theming docs for the full token table.

Documentation

Docs, demos, and customization examples at reelkit.dev/docs/lightbox.

Support

If ReelKit saved you some time, a star on GitHub would mean a lot — it's a small thing, but it really helps the project get noticed.

Star on GitHub

License

MIT

Keywords

react

FAQs

Package last updated on 27 Apr 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