Diff
Unified diffs with word-level highlights and collapsible files.
Import
import { Diff } from "@tarve/core";Usage
import { Diff } from "@tarve/core";
<Diff
oldText={"const greeting = 'hello';\nconsole.log(greeting);\n"}
newText={"const greeting = 'hello, tarve';\nconsole.log(greeting);\n"}
wordDiff
/>Props
| Prop | Type | Default |
|---|---|---|
collapsedPaths File paths rendered as headers only. | string[] | — |
maxLines Maximum changed/context lines to render per file before a Show more row. | number | — |
newText | string | — |
oldText Supply both oldText and newText to calculate a diff natively. | string | — |
onLineClick | (event: { text: string; path?: string; oldLine?: number; newLine?: number }) => void | — |
onShowMore | (hidden: number, path?: string) => void | — |
onToggleFile | (path: string) => void | — |
source A unified or git diff. | string | — |
wordDiff Enables/disables word-level emphasis inside paired changed lines. Default: true. | boolean | — |
Inherited from RichProps 1 props
| Prop | Type | Default |
|---|---|---|
syntaxTheme Overrides syntax colours without changing parsing or layout. | Partial<SyntaxTheme> | — |
Common props
Shared by every component. See descriptions →
highlightidkeymotionFromonHighlightonPasteonTransitionEndrovingGroupstyle