DS0
Components

DiffViewer

A diff viewer for comparing text changes with color-coded additions and deletions.

Overview

DiffViewer displays a side-by-side or unified diff of two text blocks, highlighting additions in green and deletions in red. Includes line numbers and optional word-level highlighting.

greet.js → greet.ts+3-2
1-function greet(name) {
2- console.log("Hello, " + name);
1+function greet(name: string) {
2+ console.log(`Hello, ${name}!`);
3+ console.log("Greeting sent.");
34 return true;
45 }

Usage

<DiffViewer
  oldValue={originalCode}
  newValue={modifiedCode}
  splitView
/>

API Reference

PropTypeDefaultDescription
oldValuestring''Original text
newValuestring''Modified text
splitViewbooleantrueSide-by-side vs. unified
showLineNumbersbooleantrueDisplay line numbers
languagestringSyntax highlighting language
ComponentWhen to Use Instead
CodeBlockSingle code block display
CodeInline code snippets

On this page