Skip to content
Calm motion: animations on this site only fade, with no movement

Diff ​

Side-by-side and inline text diff

Show what changed between two versions of a text: a config file, a document revision, an AI suggestion before you accept it. It compares line by line. To show one piece of code, use CodeBlock. To compare two images, Compare.

Basic
main.ts+3−13 lines added, 1 removed
import { createApp } from "vue";
+import { createPinia } from "pinia";
import App from "./App.vue";
const app = createApp(App);
+app.use(createPinia());
app.use(router);
app.mount("#app");
// ...
−export default app;
+export { app };
  • a is the old text and b the new. Removed lines are marked − and added lines +, with a tint as well, so the meaning does not depend on color. The header counts both, and screen readers hear "1 lines added, 1 removed".
  • mode="inline" (default) is one column with both line numbers. "split" puts the old text on the left and the new on the right, lining up lines that were replaced.
  • context folds long runs of unchanged lines, keeping that many around each change. The fold is a button ("8 unchanged lines") that opens it. Without context everything is shown.
  • Lines are compared exactly (whitespace counts), in a monospace column that scrolls sideways instead of wrapping. The comparison is a longest-common-subsequence, fine for files of a few thousand lines. A block of thousands of lines on both sides that share nothing is shown as removed and added rather than aligned.
  • diffLines(a, b) is exported if you want the rows without the component.

Usage ​

ts
import { BlessDiff } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
a*string—the old text
b*string—the new text
mode"split" | "inline""inline"
contextnumber—unchanged lines kept around each change; the rest fold away. Leave out to show everything
lineNumbersbooleantrue
labelAstring"Before"
labelBstring"After"
labelstring"Changes"

Released under the MIT License. Character names and artwork belong to their owners.