@frontendsupply/lightbox

中文文档
0.3.1发布于 2026/11/01MITTypeScriptES Module近 30 天下载 2036

Headless React lightbox and image viewer with pinch zoom, swipe, pull to dismiss and morph animations. Built on Base UI and Motion.

原始使用文档
文档目录3 节
  1. Features
  2. Docs
  3. License

Lightbox

A headless React lightbox and image viewer with pinch zoom, swipe and pull to dismiss. Thumbnails morph into the full photo and back. Built on Base UI and Motion, it ships behavior only, no CSS, so the gallery looks like your product, not like a plugin.

Docs and live demos · Made by Frontend Supply

pnpm add @frontendsupply/lightbox @base-ui/react motion
import { Lightbox } from '@frontendsupply/lightbox'

<Lightbox.Root items={photos}>
  {photos.map((photo, i) => (
    <Lightbox.Trigger key={photo.src} index={i}>
      <img src={photo.thumb} alt={photo.alt} className="aspect-square object-cover" />
    </Lightbox.Trigger>
  ))}
  <Lightbox.Portal>
    <Lightbox.Backdrop className="bg-black" />
    <Lightbox.Popup>
      <Lightbox.Viewport />
      <Lightbox.Close>Close</Lightbox.Close>
    </Lightbox.Popup>
  </Lightbox.Portal>
</Lightbox.Root>

Requires React 19 or later. Read Getting started for the full setup.

Features

  • Morph open and close that un-crops object-fit: cover thumbnails and interpolates corner radius
  • Native swiping: a real scroll-snap scroller, so touch and trackpad momentum come from the OS. Mouse dragging comes from Blossom Carousel, loaded only where there's a mouse
  • Pinch, trackpad, wheel, double-tap and keyboard zoom, with rubber-banding and inertial panning
  • Pull to dismiss with velocity carried into the close animation. Pinch below fit to close
  • Page scroll sync: the page behind the viewer follows along, so closing lands on the right thumbnail
  • Accessible: focus trap, scroll lock, Esc, focus return (Base UI Dialog) and a reduced-motion fallback
  • Headless: style every part with Tailwind, CSS modules or anything else, through data attributes and a CSS variable

Docs

License

MIT. Made by Frontend Supply.

版本与发布记录

@frontendsupply/lightbox 共发布 5 个版本,首次发布于 2026/10/20;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.3.1latest2026/11/0115 天前
0.3.02026/10/2620 天前
0.2.02026/10/2225 天前
0.1.02026/10/2125 天前
0.0.0-stage2026/10/2026 天前

关于 @frontendsupply/lightbox 的常见问题

@frontendsupply/lightbox 是什么?

Headless React lightbox and image viewer with pinch zoom, swipe, pull to dismiss and morph animations. Built on Base UI and Motion.

如何安装 @frontendsupply/lightbox?

在项目目录运行 npm install @frontendsupply/lightbox,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19)、motion(>=12)、react-dom(>=19)、@base-ui/react(^1.9.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@frontendsupply/lightbox 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@frontendsupply/lightbox 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@frontendsupply/lightbox 可以商用吗?

@frontendsupply/lightbox 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@frontendsupply/lightbox 的下载量有多少?

根据 npm 官方下载统计,@frontendsupply/lightbox 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,036 次,日均约 68 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@frontendsupply/lightbox 还在维护吗?

最新版本 0.3.1 发布于 2026/11/01(15 天前);至今共发布 5 个版本,其中过去 12 个月发布了 5 个;首次发布于 2026/10/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。