Inline Diff
A word-level diff for prose: removed words struck through, added words underlined, as one redline paragraph, a before line over an after line, or the new text alone.
oxyn add inline-diffOur agent is very careful with your data and it never shares it with anyone without asking you first.
rsx! {
InlineDiff {
before: "Our agent is very careful with your data…",
after: "Our agent is careful with your data…",
}
}Rendered from Rust at build time · goes live when visible
When to use
- Prose changed by an agent (a reply draft, a policy, release notes).
- The user wants to read the new text and see exactly which words moved, without a code gutter. rewrite_chunks tokenises both texts into words, spaces and punctuation, runs an LCS, and merges two changes separated by a single space so an edit reads as one phrase.
When not to use
- A launch countdown with digits that roll per unit, a compact one-line variant, hours absorbing days when days are hidden, and a live state with a pulsing dot at zero: use Countdown instead.
- A total that moves clearly: use Animated counter instead.
- A collapsible JSON tree with search, paging for long arrays, copy value or path, the current path under the tree and full keyboard moves: use JSON viewer instead.
Installation
Inline Diff is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add inline-diffuse crate::oxyn::{InlineDiff, STATUS_INDICATOR_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{InlineDiff, STATUS_INDICATOR_CSS};
Usage
rsx! {
InlineDiff {
before: "Our agent is very careful with your data…",
after: "Our agent is careful with your data…",
}
}Examples
Redline
Struck deletions and underlined insertions in one paragraph.
Our agent is very careful with your data and it never shares it with anyone without asking you first.
Code
rsx! {
InlineDiff {
before: "Our agent is very careful with your data…",
after: "Our agent is careful with your data…",
}
}Lines
A Before line over an After line.
BeforeRefunds are available within 14 days of purchase, if the item is unused and you contact support by email.
AfterRefunds are available within 30 days of delivery, if the item is unused. Contact support in the app or by email.
Code
rsx! {
InlineDiff {
before: "Our agent is very careful with your data…",
after: "Our agent is careful with your data…",
form: "lines",
}
}After only
Only the new words, highlighted where they changed.
Our agent is careful with your data and never shares it without asking you first.
Code
rsx! {
InlineDiff {
before: "Our agent is very careful with your data…",
after: "Our agent is careful with your data…",
form: "after-only",
}
}Review
Review mode: each change is a suggestion; the highlighted one carries Accept (Y) / Reject (N) above it, with prev / next, Reject all and Accept all below.
Refunds are available within days of , if the item is unused by email.
Code
rsx! {
InlineDiff {
before: "Our agent is very careful with your data…",
after: "Our agent is careful with your data…",
form: "review",
}
}Review partly
Two decided: the accepted wording reads as plain text, the rejected one is back to the original, the count drops and Undo appears.
Refunds are available within 30 days of purchase, if the item is unused by email.
Code
rsx! {
InlineDiff {
before: "Our agent is very careful with your data…",
after: "Our agent is careful with your data…",
form: "review",
}
}Review done
Everything decided: a green check, All changes reviewed and Undo.
Our agent is careful with your data and never shares it without asking you first.
Code
rsx! {
InlineDiff {
before: "Our agent is very careful with your data…",
after: "Our agent is careful with your data…",
form: "review",
}
}Review classic
Classic review: the buttons sit above the text and changes are colour plus strike or underline, no tint.
Refunds are available within days of , if the item is unused by email.
Code
rsx! {
InlineDiff {
before: "Our agent is very careful with your data…",
after: "Our agent is careful with your data…",
form: "review",
}
}API reference
InlineDiff
| Prop | Type | Default | Description |
|---|---|---|---|
beforerequired | String | — | Old text. |
afterrequired | String | — | New text. |
form | String | "inline" | `inline` · `lines` · `after-only`. |
counts | bool | true | Show the +/− word counts. |
review | bool | Default::default() | Review mode: each change is a suggestion to accept (Y) or reject (N), one at a time or all at once, with Undo. |
label | String | "Suggested edit · Tighten it" | Review mode: the line above the text. |
decided | Vec<Option<bool>> | Default::default() | Review mode: decisions made from the start (`Some(true)` accepted). |
style | String | Default::default() | Review mode: `clean`, `classic`, or empty to follow `data-cstyle`. |
on_change | EventHandler<String> | — | Review mode: the text after each decision. |
on_done | EventHandler<String> | — | Review mode: the final text once nothing is left to decide. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Read-only forms: no stops. Review: each suggestion, then the footer buttons |
| YorN | Review: accept / reject the highlighted suggestion |
| Enter | Review: highlight the focused suggestion |
Accessibility
- Deletions and insertions are real del and ins elements, so screen readers announce them; colour is paired with strike-through and underline.
- In review every change is its own button whose name gives its place, the words it swaps and the Y / N keys; each decision is read out by a polite status line.
- Neighbouring single-word changes merge into phrases, so the paragraph reads as a few edits, not confetti.
From the spec
- Real
delandinselements, announced by screen readers; colour is paired with strike-through and underline. - The +N / −N word counts are text.
Motion & interaction
Timing
- No motion of its own: it renders a settled diff. Hosts that stream wrap it in a text reveal.
- Reduced motion: nothing to reduce.
Responsive behaviour
- Wraps like any paragraph; fills its column up to 640 px.
Edge cases (spec)
- Wraps like a paragraph; max 640 px.
Notes for AI
- Import
InlineDifffromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
InlineDiffElinoxyn_gpui. - Props to set first:
before,after. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.