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
| 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 }; | ||
ais the old text andbthe 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.contextfolds long runs of unchanged lines, keeping that many around each change. The fold is a button ("8 unchanged lines") that opens it. Withoutcontexteverything 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
| Name | Type | Default | Description |
|---|---|---|---|
a* | string | — | the old text |
b* | string | — | the new text |
mode | "split" | "inline" | "inline" | |
context | number | — | unchanged lines kept around each change; the rest fold away. Leave out to show everything |
lineNumbers | boolean | true | |
labelA | string | "Before" | |
labelB | string | "After" | |
label | string | "Changes" |