Loading component…
Loading component…
AI edits to prose shown inline – struck and added words you accept or reject one by one, with keys, a popover and undo
To reuse this local React demo, copy all files from the Code tab into the same folder, then import InlineDiff from ./inline-diff.
import { InlineDiff } from "@/components/ui/inline-diff";
export function ReviewRewrite({ draft, rewrite }: { draft: string; rewrite: string }) {
return (
<InlineDiff
label="Suggested by AI · Make it shorter"
original={draft}
suggested={rewrite}
onChange={(text) => saveDraft(text)}
onDone={(text) => setFinal(text)}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| original | string | "" | The text as it is now |
| suggested | string | "" | The text the AI suggests – diffed word by word against original |
| changes | DiffSegment[] | Pre-computed segments ({ type: "equal", text } or { type: "change", remove, insert }) instead of original and suggested | |
| onChange | (text: string) => void | Called on every decision and undo with the text so far – pending changes keep the original words | |
| onDone | (text: string) => void | Called when the last pending change is decided, with the final text | |
| label | string | Small line on the gray tray above the card, e.g. "Suggested by AI · Make it shorter" | |
| className | string | Extra class on the root |
Fills its container; the paragraph wraps freely and changes wrap across lines with their tints
The popover stays inside the card horizontally, down to 320px wide
Below 400px the prev/next arrows step aside; on touch screens the popover buttons grow and drop the key hints
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"