Prodular UI

AI

DiffAIPro

A text diff with inline and split modes, word level highlights inside changed lines and optional line numbers. Shows what an AI edit or a new version changes.

npx prodular-ui add diff

Part of Prodular UI Pro. Preview and read the docs freely, install with a license. See pricing

Inline

Removed and added lines stacked, with the changed words highlighted inside them.

second-notice.tmpl
+6-5
Removed: subject: Invoice {{invoice.number}} is overdue
Added: subject: A reminder about invoice {{invoice.number}}
from: ar@ledgerline.app
Removed: delay_days: 7
Removed: tone: firm
Added: delay_days: 10
Added: tone: friendly
Hi {{contact.first_name}},
Removed: Invoice {{invoice.number}} for {{invoice.total}} is now overdue.
Removed: Please pay it as soon as possible.
Added: Invoice {{invoice.number}} for {{invoice.total}} was due on {{invoice.due_date}}.
Added: You can pay it in a minute with the link below.
Added: Reply to this email if anything looks wrong.

Split

Before and after side by side. variant="prose" uses the UI font and wraps long lines.

Field policy, version 4 to 5
+3-3
Technicians must check in at the site office on arrival.
Technicians check in through the app on arrival.
Visits over 2 hours need a supervisor sign off.
Visits over 2 hours need a supervisor sign off.
Parts under $200 can be bought on the company card.
Parts under $350 can be bought on the company card.
Photos are optional for completed jobs.
Upload at least 2 photos before closing a job.

Inline text

DiffText flows inside a paragraph. Used by Inline Assist to show a proposed edit in place.

Close for Q3 is basicallysubstantially donecomplete. We're are still waiting on 3 vendor credits, which meansso accounts payable is a little higher than it shouldtemporarily beoverstated.

The Team plan grew faster than we expected after the July price change. With showRemoved off, only additions are marked.

Anatomy

<Diff before={original} after={proposed} lineNumbers>  <DiffHeader>    <DiffTitle>second-notice.tmpl</DiffTitle>    <DiffStat />  </DiffHeader></Diff>

Guidance

Use it when

  • Show a diff before anyone accepts a change the model proposed to existing text, a template or a config.
  • Use mode="inline" in narrow spaces and mode="split" when there is room and lines change a lot.
  • Use variant="prose" for sentences and paragraphs, variant="code" for templates, configs and code.
  • Use DiffText inside running text, for example a proposed rewrite of one paragraph.

Avoid

  • Showing only the new version of a generated edit. People need to see what is removed.
  • Diffs of very long documents in one view. Diff the section that changed.
  • Coloring removed and added text yourself. The component uses the success and destructive subtle tokens.

Rules for AI agents

Published in llms-full.txt and the registry, so coding agents follow them when they build with this component.

  • Pass the original text as before and the proposed text as after, as plain strings. Do not pre mark changes.
  • Pair every AI proposed edit with a diff and explicit Accept and Reject actions. Never apply the after text on render.
  • Turn lineNumbers on for code and configs, off for prose.
  • Put DiffHeader with DiffTitle and DiffStat inside Diff when the diff stands alone, so people know what file or document changed.

API

Diff

PropTypeDefaultDescription
before / afterstringThe original and the changed text.
mode"inline" | "split""inline"Stacked or side by side. Exposed as data-mode.
variant"code" | "prose""code"Mono and no wrapping, or UI font with wrapping.
lineNumbersbooleanfalseOld and new line numbers.
wordLevelbooleantrueHighlight changed words inside changed lines.

DiffText

PropTypeDefaultDescription
before / afterstringA word level diff that flows inside text.
showRemovedbooleantrueHide deletions to preview the result.

diffWords / diffLines

PropTypeDefaultDescription
(before, after)DiffOp<string>[]The underlying diff, if you need to render it yourself.