Revisions of a record: pick two, see what changed and restore an older one. Text diffs highlight changed words inside changed lines (jsdiff), side by side or unified, with collapsed unchanged runs and change navigation. Records diff field by field with locale formatting.
Select two versions to compare.
- v4 · Pricing and allergensCurrentİlker Şahin · 11/10/26, 9:12 AMUpdated reprint cost, added allergens and staff training.After
- v3PublishedMeltem Öz · 11/8/26, 4:40 PMBefore
- v2Autosaveİlker Şahin · 11/7/26, 11:05 AM
- v1 · Outlineİlker Şahin · 11/5/26, 8:30 AM
v3v4 · Pricing and allergens
Installation
The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";
Usage
import { VersionHistory, DiffView, FieldDiff } from "@vamos-ui/react";
<VersionHistory
versions={revisions}
loadVersion={(id) => api.revision(id).then((r) => r.body)}
onRestore={(id) => api.restore(postId, id)}
/>
<DiffView before={a} after={b} mode="split" />
<FieldDiff before={v1} after={v2} fields={[{ key: "amount", label: "Amount", format: "currency" }]} />Colour is never the only signal: +/− gutters, <ins>/<del> and screen-reader text ("Added line"). Diff panels are surface-2 and never blurred in glass mode.
Examples
Word, character and line diff
mode="split" puts before at the start side; granularity controls the in-line highlights.
Record changes (CRM quote)
Values use the field's format; long text fields (type="text-long") get a word diff.
| Field | Quote v2 · Nov 3 | Quote v3 · Nov 9 |
|---|---|---|
| AmountChanged | $52,000.00 | |
| DiscountChanged | 12% | |
| StageChanged | Negotiation | |
| OwnerChanged | Ayşe Kaya | |
| SeatsChanged | 45 | |
| SSO includedChanged | Yes | |
| TermsChanged | Removed line: Annual billing, net Added line: Annual billing, net 45. Price locked for 12 months if signed by Dec 15. | |
Long document, collapsed hunks (HR policy)
context sets the unchanged lines kept around each change. Focus the diff and press n / p to jump between changes.
API
VersionHistory
| Prop | Type | Default |
|---|---|---|
versionsRevisions (any order; shown newest first). | Version[] | — |
loadVersionContent of one version: text → DiffView, record → FieldDiff. Cached per id. | (id) => string | Record<string, unknown> | Promise<…> | — |
compare / defaultCompare / onCompareChangeThe pair being compared; older is "before". | [string, string] / … / (pair) => void | — |
fieldsRecord versions: fields to compare. | FieldDiffField[] | — |
onRestore"Restore this version" with a confirm dialog, then a success toast. | (id) => void | Promise<void> | — |
layoutList beside the diff, or stacked for a Sheet. | "page" | "panel" | "page" |
defaultModeText diff layout. | "split" | "unified" | page: "split", panel: "unified" |
granularityIn-line highlights. | "word" | "char" | "line" | "word" |
contextUnchanged lines kept around changes. | number | 3 |
labelsAll built-in strings. | Partial<VersionHistoryLabels> | — |
Version
| Prop | Type | Default |
|---|---|---|
id / createdAtIdentity and time. | string / ISO instant | — |
label / summary"v12 · Pricing update" and a short note. | string | — |
authorWho saved it. | { name; avatar? } | — |
kindBadge. | "manual" | "autosave" | "published" | "system" | "manual" |
currentThe live version. | boolean | — |
DiffView
| Prop | Type | Default |
|---|---|---|
before / afterTexts to compare. | string | — |
modeLayout. | "unified" | "split" | "unified" |
granularityIn-line highlights. | "word" | "char" | "line" | "word" |
contextCollapsed context; Infinity shows all. | number | 3 |
beforeLabel / afterLabelColumn and region names. | string | — |
lineNumbers / toolbar / wrapGutters; summary + prev/next; wrap long lines. | boolean | true |
actionsExtra toolbar content. | ReactNode | — |
FieldDiff
| Prop | Type | Default |
|---|---|---|
before / afterRecords to compare. | Record<string, unknown> | — |
fieldsFields in order. Default: every key, humanized. | { key; label; format?; type?: "text" | "text-long" | "boolean" | "list" | "json"; render? }[] | — |
onlyChangesHide unchanged fields. | boolean | true |
beforeLabel / afterLabelColumn headers. | string | — |
Helpers
| Prop | Type | Default |
|---|---|---|
diffText(before, after, granularity)The line model behind DiffView. | DiffLine[] | — |
diffRecords(a, b, fields?)added / removed / changed / same per field. | { key; change; before; after }[] | — |