Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Code Diff Viewer

ProNew

Line-numbered code listing and unified diff viewer with a gliding Diff/Final switcher, +/- counters, and copy button.

Installation

pnpm dlx shadcn@latest add @viewport/code-diff-viewer

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
filename*string

File path shown in the header, e.g. "src/lib/batch.ts".

—
lines*DiffLine[]

Unified diff lines; the "Final" view derives automatically from context + add lines.

—
defaultMode"diff" | "code"

Initial view mode.

"diff"
classNamestring—

Accessibility

  • Mode switcher uses tablist/tab semantics; copy button updates its accessible label.
  • Horizontal scrolling keeps long lines readable on narrow mobile screens.
  • View transitions disable under reduced motion.