@juxtapose/storybook

中文文档
0.13.0发布于 2026/11/01MITTypeScriptES Module构建来源已验证

Storybook addon for juxtapose — review visual diffs next to the story that produced them.

原始使用文档

@juxtapose/storybook

Storybook addon for juxtapose — review visual diffs next to the story that produced them.

pnpm add -D @juxtapose/storybook
// .storybook/main.js
export default {
  addons: ['@juxtapose/storybook'],
};

A Juxtapose tab appears in the addon panel. From there you can capture the current story or the whole suite, compare against the baseline four ways (side by side with a diff overlay, a draggable slider, an onion crossfade, or flicker), approve changes, and copy a prompt with the recorded changes and image paths for your agent.

juxtapose also registers as a test provider: a Juxtapose row in Storybook's testing module at the bottom of the sidebar, and Storybook's Run tests button runs the visual suite alongside your other tests. The test provider needs Storybook 8.5 or later and is checked against 8.6 and 10.6. On earlier versions the row doesn't appear; the panel works either way.

The What changed section uses the existing report's structural summary, with expandable before/after details, evidence limits, and unexplained regions. When available, it also shows flake evidence and suggested configuration you can select and copy. Suggestions are not applied automatically. Renderer recovery reports an exact hash match when successful; it does not establish a root cause. These explanations require no additional captures or analysis.

Capture errors, cancellation, and failed runs are shown explicitly. A failed run may leave the previous report visible, labelled as such. Approval is unavailable for capture errors or confirmed unstable results; eligible approvals still take a fresh confirming capture. Missing baseline images show the current capture and available structural evidence, without comparison controls.

Keyboard: j/k next and previous pending capture (including variants), a approve, s side by side, w wipe slider, o onion, f flicker, d diff overlay, u dim unchanged areas, and z loupe. Shortcuts ignore text inputs, modifier keys, and repeated key events. Approval shortcuts obey the same guards as the buttons.

The wipe slider supports pointer dragging, arrow keys (1%; Shift for 10%), and Home/End. Flicker has a pause/play control, starts paused when reduced motion is requested, and pauses while the browser tab is hidden. If copying an agent prompt fails, its text remains selectable in the panel.

The addon mounts its API inside Storybook's own dev server, so there is no second process to run and no port to configure.

MSW-backed stories are supported: Storybook captures allow service workers. Configure MSW in your Storybook, serve its worker asset in both development and static builds, and await worker readiness in your preview/loader before fetching mocked data. The addon does not install or configure MSW for you. CI verifies real MSW responses in repeated captures; the example's Msw.stories.jsx shows the setup. This is separate from URL-only jux snap, which blocks service workers.

Full documentation: https://github.com/juxtapose-dev/juxtapose

MIT © Magic Factory LLC

版本与发布记录

@juxtapose/storybook 共发布 44 个版本,首次发布于 2026/07/29;过去 12 个月发布了 44 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.13.0latest2026/11/011 天前
0.12.132026/10/312 天前
0.12.122026/10/313 天前
0.12.112026/10/304 天前
0.12.102026/10/294 天前
0.12.92026/10/295 天前

关于 @juxtapose/storybook 的常见问题

@juxtapose/storybook 是什么?

并列的故事书插件-审查视觉差异旁边的故事,产生了他们。

如何安装 @juxtapose/storybook?

在项目目录运行 npm install @juxtapose/storybook,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18 || ^19)、storybook(^8 || ^9 || ^10)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@juxtapose/storybook 支持 TypeScript 吗?

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

@juxtapose/storybook 支持 ESM 还是 CommonJS?

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

@juxtapose/storybook 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.2.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@juxtapose/storybook 可以商用吗?

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

@juxtapose/storybook 还在维护吗?

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