DiffView

A line diff. Changed lines slide in from their side, the part that really changed is marked, and a thumb switches between one column and two. Data.

Open playground
+3 −2
const spring = {
Removed: stiffness: 300,
Removed: damping: 20,
Added: stiffness: 280,
Added: damping: 22,
Added: mass: 1,
};
export default spring;

About

DiffView is a React component in the Data category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { DiffView } from "@ashutoshswamy/smoui" and set before, defaultMode, beforeLabel.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { DiffView } from "@ashutoshswamy/smoui";

<DiffView before={oldText} after={newText} defaultMode="split" />

Props 3

before / after

Two versions; lines are split on newlines.

string
defaultMode

Starting view.

"unified""split"default "unified"
beforeLabel / afterLabel

Headings in split mode.

string