DiffViewer

Shows two versions of a record, one row per field, side by side or inline. The viewer fetches nothing: it compares the before and after it is given, field by field, by deep equality. Null and undefined read as missing, and <ins> and <del> mark the values.

Installation

pnpm dlx shadcn@latest add @chelone/diff-viewer
Loading preview…

Shows two versions of a record, one row per field, side by side or inline. The viewer fetches nothing: it compares the before and after it is given, field by field, by deep equality. Null and undefined read as missing, and <ins> and <del> mark the values.

Props

PropTypeDefaultDescription
afterTRecord—The later version.
beforeTRecord—The earlier version.
classNamestring—
formattersPartial<Record<string, (value: unknown) => ReactNode>>—A renderer per source, replacing the default value text.
labelsPartial<Record<string, ReactNode>>—A label per source, replacing the translated field label.
modeDiffViewerMode—Table (`side-by-side`, the default) or list (`inline`).
resourcestring—Resource whose field labels apply. Defaults to the ambient resource.
sourcesreadonly SourceProp<TRecord>[]—Fields to show, in this order. Without it: every top-level key.