Review what an agent changed: unified or split diffs with word-level marks, accept or reject each hunk, and a summary of every file it touched.
Examples
Installation
Installation is part of Pro
Pro components install from a licensed registry. The live preview stays open to everyone.
Props
- InlineDiff · before / after
string- The file before and after; the line diff is computed here (Myers). Unchanged runs between hunks fold away and can be shown.
- InlineDiff · patch / hunks
string / Hunk[]- Or a one-file unified diff ("@@ -a,b +c,d @@" blocks), or hunks you already have.
- InlineDiff · view / defaultView / onViewChange
"unified"|"split"- Default
"unified" - Unified, or side by side with deletions paired to additions. Switch in the header.
- InlineDiff · onHunk / decisions
(index, decision | null, hunk) => void / Record<index, decision>- Accept / Reject on each hunk (Undo after). Rejected hunks dim. Kept internally unless you pass decisions.
- InlineDiff · context / wrap / path / header / actions
number / boolean / ReactNode / boolean / ReactNode- Default
3 / split: true / - / true / - - Lines kept around changes, wrapping long lines (else they scroll sideways), the file path and +/− counts in the header.
- Highlighting
-- No syntax colours: changed lines are tinted, and the words that changed inside a line stand out (<ins> / <del>). Screen readers hear "Added" / "Removed".
- ChangeSummary · files
{ path, oldPath?, status?, before?, after?, patch?, added?, removed? }[]- Each file with its status (A / M / D / R), +/− counts and a five-block bar. Without contents, a file is listed with your counts only.
- ChangeSummary · patch
string- Or a whole multi-file git patch; statuses come from its headers (new, deleted, renamed).
- ChangeSummary · onHunk / defaultExpanded / view
(path, index, decision, hunk) => void / string[] / view- Open a file to see its diff (one view switch for all, Expand all / Collapse all) and decide per hunk.
| Prop | Type | Default | Description |
|---|---|---|---|
| InlineDiff · before / after | string | - | The file before and after; the line diff is computed here (Myers). Unchanged runs between hunks fold away and can be shown. |
| InlineDiff · patch / hunks | string / Hunk[] | - | Or a one-file unified diff ("@@ -a,b +c,d @@" blocks), or hunks you already have. |
| InlineDiff · view / defaultView / onViewChange | "unified" | "split" | "unified" | Unified, or side by side with deletions paired to additions. Switch in the header. |
| InlineDiff · onHunk / decisions | (index, decision | null, hunk) => void / Record<index, decision> | - | Accept / Reject on each hunk (Undo after). Rejected hunks dim. Kept internally unless you pass decisions. |
| InlineDiff · context / wrap / path / header / actions | number / boolean / ReactNode / boolean / ReactNode | 3 / split: true / - / true / - | Lines kept around changes, wrapping long lines (else they scroll sideways), the file path and +/− counts in the header. |
| Highlighting | - | - | No syntax colours: changed lines are tinted, and the words that changed inside a line stand out (<ins> / <del>). Screen readers hear "Added" / "Removed". |
| ChangeSummary · files | { path, oldPath?, status?, before?, after?, patch?, added?, removed? }[] | - | Each file with its status (A / M / D / R), +/− counts and a five-block bar. Without contents, a file is listed with your counts only. |
| ChangeSummary · patch | string | - | Or a whole multi-file git patch; statuses come from its headers (new, deleted, renamed). |
| ChangeSummary · onHunk / defaultExpanded / view | (path, index, decision, hunk) => void / string[] / view | - | Open a file to see its diff (one view switch for all, Expand all / Collapse all) and decide per hunk. |
Prose mode
Read only, collapsed
Installation is part of Pro
Pro components install from a licensed registry. The live preview stays open to everyone.
- before / after
string / string- The text and the AI's rewrite. Suggestions are worked out word by word; neighbouring changes become one suggestion.
- onChange
(text, decisions) => void- After every decision, with the resulting text. Undecided suggestions keep the old words.
- onDone
(text) => void- Once every suggestion has a decision.
- toolbar
boolean- Default
true - Counts, previous / next, Undo, Reject all and Accept all.
- mode / readOnly
"review"|"read" / boolean- Default
"review" - "read" (or readOnly) renders the same inline word diff for a history view: no Accept / Reject, no toolbar, no focus targets, no pending state, no status line. onChange and onDone never fire.
- collapseUnchanged / contextLines
boolean / number- Default
false / 2 - Fold each long unchanged stretch into a "… N unchanged lines" button that opens with a short fold, keeping contextLines lines around every change.
- author / onWritten
{ name, speed? } / () => void- A co-writer writing the suggestions live: they appear one after the other, the old words struck and the new ones typed in behind a cursor with this name. Nothing can be decided until the last is written, then onWritten fires.
- toolbarStyle / lead
"full"|"slim" / ReactNode- Default
"full" - slim is one compact row docked above the text, starting with the lead (who is suggesting), with no status line.
- decide / inherit
"labels"|"icons" / boolean- Default
"labels" / false - icons shows only a check and a cross in each suggestion's popover. inherit takes the text size and colour of the surroundings, so the diff can sit inside a document.
- Keys
-- On a suggestion: Y or Enter accepts, N or Backspace rejects, arrows (or J / K) move, Ctrl/Cmd + Z undoes. A status line announces each decision.
| Prop | Type | Default | Description |
|---|---|---|---|
| before / after | string / string | - | The text and the AI's rewrite. Suggestions are worked out word by word; neighbouring changes become one suggestion. |
| onChange | (text, decisions) => void | - | After every decision, with the resulting text. Undecided suggestions keep the old words. |
| onDone | (text) => void | - | Once every suggestion has a decision. |
| toolbar | boolean | true | Counts, previous / next, Undo, Reject all and Accept all. |
| mode / readOnly | "review" | "read" / boolean | "review" | "read" (or readOnly) renders the same inline word diff for a history view: no Accept / Reject, no toolbar, no focus targets, no pending state, no status line. onChange and onDone never fire. |
| collapseUnchanged / contextLines | boolean / number | false / 2 | Fold each long unchanged stretch into a "… N unchanged lines" button that opens with a short fold, keeping contextLines lines around every change. |
| author / onWritten | { name, speed? } / () => void | - | A co-writer writing the suggestions live: they appear one after the other, the old words struck and the new ones typed in behind a cursor with this name. Nothing can be decided until the last is written, then onWritten fires. |
| toolbarStyle / lead | "full" | "slim" / ReactNode | "full" | slim is one compact row docked above the text, starting with the lead (who is suggesting), with no status line. |
| decide / inherit | "labels" | "icons" / boolean | "labels" / false | icons shows only a check and a cross in each suggestion's popover. inherit takes the text size and colour of the surroundings, so the diff can sit inside a document. |
| Keys | - | - | On a suggestion: Y or Enter accepts, N or Backspace rejects, arrows (or J / K) move, Ctrl/Cmd + Z undoes. A status line announces each decision. |
When to use
When to use
- Reviewing code or text an agent changed, with word-level marks and accept or reject per hunk.
- A change summary of every file a run touched, before the user commits to it.
When not to use
- Showing raw tool input and output as JSON: use Tool Call Card.
- Very large generated files: a diff view of thousands of lines is slow to read; link to the file instead.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Inline Diff to my app and wire it to my own data.
- I need reviewing code or text an agent changed, with word-level marks and accept or reject per hunk. Set that up with the Knowns UI Inline Diff.
- Which Inline Diff props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "diff" }) and search_docs({ query: "inline diff" }). Pro props, full examples and source come back once your license key is in the MCP config.