InkUI
Components

DiffView

Unified diff viewer with add/remove highlighting — LCS algorithm, no external deps.

Display text diffs with colored additions and deletions. Uses a built-in LCS-based diff algorithm with no external dependencies.

Live Preview
DiffView · unified diff viewer
@@ -2,4 +2,5 @@
import express from 'express'
- const PORT = 3000
+ const PORT = process.env.PORT ?? 3000
+ const HOST = '0.0.0.0'
app.listen(PORT)
~/my-cli — node v22● running

Installation

npx inkui add diff-view

Usage

import { DiffView } from './components/ui/diff-view';
 
const before = `const retries = 3;
const timeout = 30;`;
 
const after = `const retries = 5;
const timeout = 30;
const debug = true;`;
 
export default function App() {
  return (
    <DiffView
      before={before}
      after={after}
      beforeLabel="v1"
      afterLabel="v2"
    />
  );
}

API Reference

PropTypeDefaultDescription
beforestringOriginal text (required)
afterstringModified text (required)
mode'unified' | 'split''unified'Display mode
showLineNumbersbooleantrueShow line numbers
contextLinesnumber3Unchanged lines around changes
maxHeightnumberMax visible rows
beforeLabelstring'Before'Label for original
afterLabelstring'After'Label for modified
showBorderbooleantrueShow rounded border
themeInkUIThemedarkThemeColor theme

On this page