Diff Viewer
High-performance text diff viewer with unified, split, inline, and minimal variants. Handles very large files via row virtualization, supports ignore options and a configurable comparison cap.
Basic Usage
Unified Diff
Classic git-style unified diff with word-level highlights on changed lines.
import { DiffViewer } from 'fluxo-ui';
<DiffViewer
oldValue={oldText}
newValue={newText}
oldTitle="before.js"
newTitle="after.js"
/>Variants
Split View
Side-by-side two-column layout.
<DiffViewer variant="split" oldValue={...} newValue={...} />
<DiffViewer variant="inline" oldValue={...} newValue={...} />
<DiffViewer variant="minimal" collapseUnchanged oldValue={...} newValue={...} />Inline Diff
Compact inline word-level diff for small snippets.
Collapse Unchanged
Runs of unchanged lines are folded into context hunks.
Ignore Options
Ignore Options
Toggle whitespace, case, and empty-line sensitivity.
<DiffViewer
oldValue={oldText}
newValue={newText}
ignoreWhitespace
ignoreCase
ignoreEmptyLines
/>Interactive Viewer
Interactive Diff Viewer
File list on the left, diff on the right. Switch between unified and split view, toggle word highlighting and ignore options.
<DiffViewer
variant={view}
oldValue={selectedFile.oldValue}
newValue={selectedFile.newValue}
oldTitle={`${selectedFile.name} (before)`}
newTitle={`${selectedFile.name} (after)`}
wordDiff={wordDiff}
ignoreWhitespace={ignoreWs}
ignoreCase={ignoreCase}
ignoreEmptyLines={ignoreEmpty}
collapseUnchanged={3}
/>Large Files
Large File Performance
Virtualized rendering. 2000+ lines diff smoothly. Use maxLines to cap comparison.
<DiffViewer
oldValue={oldLarge}
newValue={newLarge}
variant="split"
collapseUnchanged
maxLines={5000}
maxHeight={500}
/>Import
import { DiffViewer } from 'fluxo-ui';
import type { DiffViewerProps, DiffVariant } from 'fluxo-ui';Props
oldValuestringThe old/before text.
oldValuestringThe old/before text.
newValuestringThe new/after text.
newValuestringThe new/after text.
variant'unified' | 'split' | 'inline' | 'minimal'"'unified'"Diff display style.
variant'unified' | 'split' | 'inline' | 'minimal'"'unified'"Diff display style.
oldTitlestringHeader label for the old side.
oldTitlestringHeader label for the old side.
newTitlestringHeader label for the new side.
newTitlestringHeader label for the new side.
showLineNumbersboolean"true"Show gutter line numbers.
showLineNumbersboolean"true"Show gutter line numbers.
wordDiffboolean"true"Highlight word-level changes inside replaced lines.
wordDiffboolean"true"Highlight word-level changes inside replaced lines.
collapseUnchangedboolean | number"false"Fold unchanged runs. A number sets the context line count (default 3).
collapseUnchangedboolean | number"false"Fold unchanged runs. A number sets the context line count (default 3).
maxHeightnumber | string"480"Max scroll viewport height.
maxHeightnumber | string"480"Max scroll viewport height.
ignoreWhitespaceboolean"false"Collapse whitespace runs when comparing.
ignoreWhitespaceboolean"false"Collapse whitespace runs when comparing.
ignoreCaseboolean"false"Case-insensitive comparison.
ignoreCaseboolean"false"Case-insensitive comparison.
ignoreEmptyLinesboolean"false"Treat blank lines as equal.
ignoreEmptyLinesboolean"false"Treat blank lines as equal.
maxLinesnumberStop comparing after N lines. Larger files are truncated with a footer notice.
maxLinesnumberStop comparing after N lines. Larger files are truncated with a footer notice.
rowHeightnumber"22"Row pixel height used for virtualization.
rowHeightnumber"22"Row pixel height used for virtualization.
highlight(line: string) => ReactNodeCustom syntax-highlight hook.
highlight(line: string) => ReactNodeCustom syntax-highlight hook.