$ rezi
Widgets

DiffViewer

Renders unified or side-by-side diffs with hunk navigation.

Renders unified or side-by-side diffs with hunk navigation.

Usage

ui.diffViewer({
  id: "diff",
  diff: state.diff,
  mode: "unified",
  scrollTop: state.scrollTop,
  lineNumbers: true,
  contextLines: 3,
  onScroll: (top) => app.update((s) => ({ ...s, scrollTop: top })),
  onStageHunk: (i) => stageHunk(i),
  onRevertHunk: (i) => revertHunk(i),
})

Props

PropTypeDefaultDescription
idstringrequiredWidget identifier
diffDiffDatarequiredDiff data model
mode"unified" | "sideBySide"requiredRender mode
scrollTopnumberrequiredScroll offset (lines)
lineNumbersbooleantrueShow line numbers
contextLinesnumber3Context lines around changes
expandedHunksnumber[]-Hunks expanded beyond default threshold
focusedHunknumber-Focused hunk index
onScroll(scrollTop) => voidrequiredScroll callback
onHunkToggle(index, expanded) => void-Expand/collapse callback
onStageHunk(index) => void-Stage callback
onUnstageHunk(index) => void-Unstage callback
onApplyHunk(index) => void-Apply callback
onRevertHunk(index) => void-Revert callback
focusConfigFocusConfig-Control focus visuals; { indicator: "none" } suppresses focus decoration
scrollbarVariant"minimal" | "classic" | "modern" | "dots" | "thin""minimal"Scrollbar glyph variant
scrollbarStyleTextStyle-Style override for scrollbar

Scrollbar

A vertical scrollbar is rendered on the right edge when content exceeds the viewport height. Set scrollbarVariant to choose a glyph style. Use scrollbarStyle to override scrollbar colors.

Mouse Behavior

  • Mouse scroll wheel scrolls diff content, firing the onScroll callback. Scroll works when hovering over the widget, even without focus.
  • Clicking the viewer area focuses the widget.

Notes

  • DiffData includes file paths, hunks, and optional binary flag.
  • Provide expandedHunks to keep large hunks open by default.

On this page