Inline Diff
AI edits to prose, shown in the prose, accepted or rejected one phrase at a time.
PROGet Inline Diff and 168 other Pro components with pro lifetime — Get Pro
- Category
- AI Agent
- Access
- ProPro · unlocked
- Source
- 499 lines · one file
- States
- 7 drawn
- Added
- 21 Oct 2026
The decision inside it
A change is a whole phrase, and your edits are safe
A word-level diff of a rewritten sentence turns into confetti. Neighbouring edits are merged into one phrase you decide once. If you typed over a phrase since the suggestion was made, Accept asks "Replace your edit?" instead of throwing your words away.
When to use it
Use Inline Diff to review an AI rewrite of prose: changes are whole phrases you accept or reject in the text, by click or by key, with undo. Pass the original and the suggestion, or changes you worked out yourself. For structured record changes use Dry-Run Preview.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Inline Diff for this.
Install it: npx shadcn@latest add @liro/inline-diff
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/inline-diff.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { InlineDiff } from "@/components/ui/inline-diff";
export function ReviewRewrite({ draft, rewrite, save }: { draft: string; rewrite: string; save: (text: string) => void }) {
return (
<InlineDiff
original={draft}
suggested={rewrite}
onDone={(result) => save(result.text)}
/>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
original | string | Yes | The text the suggestion was made against. |
suggested | string | No | The suggested text. Diffed against `original` by word and grouped into phrases. |
changes | Change[] | No | Or the changes, already worked out. Each `from` is found in `original`, in order. |
reasons | Record<string, string> | No | Reasons by change id, for computed changes. |
onChange | (text: string) => void | No | The resulting text, after every decision. |
onDone | (result: InlineDiffResult) => void | No | When nothing is left to decide. |
defaultDecisions | Record<string, Decision> | No | Decisions already made, by change id (for a saved review). |
readOnly | boolean | No | Show the diff without actions. |
title | string | No | Default "Suggested edits". |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themebuttonStates
All of them are drawn by the component. None is left for you to design.
- Suggestions
- Change open
- Accepted
- Rejected
- Overlaps your edit
- All decided
- Read only
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances