Text Diff
Compares two strings: unified or split, line numbers, unchanged regions folded behind Expand N lines, changed words highlighted, syntax colours by language, word wrap, line selection and find in page; inputs past 200k characters diff in a Web Worker.
Example
@@ -1,5 +1,5 @@
Removed, line 1
Added, line 1
Line 2
Removed, line 3
Removed, line 4
Added, line 3
Added, line 4
Line 5
text-diff-demo.tsxCopy code
Installation
Copy code
Usage
ImportCopy code
Use TextDiff to compare two versions of one text: a config, a generated file, an edit before saving. language picks the syntax colours; context sets the unchanged lines around each change; inputs past 200k characters diff in a Web Worker.
API reference
TextDiff
Takes Omit<DiffViewProps, "files" | "headers"> &.
Other exports
useTextDifftype TextDiffInputtype TextDiffPropsAccessibility
- One tab stop over the lines; arrows, j/k between changes, Enter to expand a folded region or select a line.
- Signs, line numbers and screen-reader labels mark every change; changed words are highlighted on top of the line fill.
Agent actions
The same diff component and actions as GitDiff, with one file.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.