AI Suggestion Diff
An AI rewrite shown as inline changes you can accept or reject one by one, or all at once.
AI prompt
Clean writing assistant UI showing a paragraph with tracked AI edits inline, deleted phrases in red strikethrough and inserted phrases in green underline, below it a list of three suggested changes each with a small Accept and Reject button, a header with Accept all and Reject all, and a quiet line 2 changes pending, light theme, flat modern style, comfortable spacing. Negative: chat bubbles, robots, gradients, text errors, clutter. Reduced motion: static design.About this pattern
Definition
When an AI edits your text, show the changes instead of silently replacing it. Removed words are struck through, added words are highlighted, and each change has its own accept and reject controls, so people stay in control of their writing.
Purpose & UX principles
- Show deletions and insertions inline in the paragraph.
- Give each change Accept and Reject; add Accept all and Reject all.
- Show the live result and a count of what is pending.
- Do not apply anything until the person decides, and make it easy to undo.
Interaction states
- Three suggested changes, per-change buttons and bulk actions.
Motion specification
- Text updates instantly.
- Reduced motion: nothing animates.
Responsive behaviour
- Do not rely on colour alone: use strikethrough and underline too.
- Announce the new counts to screen readers.
Code
<div class="bx"><div class="hd2"><b>AI suggestions</b><span><button class="mini" id="aa" type="button">Accept all</button> <button class="mini" id="ra" type="button">Reject all</button></span></div><p class="tx" id="tx"></p><ul class="ls" id="ls"></ul><p class="out" id="out" role="status"></p></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.hd2{display:flex;justify-content:space-between;align-items:center;font-size:12.5px}.tx{border:1px solid var(--line);border-radius:10px;background:var(--surface);padding:8px 10px;font-size:12.5px;line-height:1.6}.tx del{color:#c62f2f;text-decoration:line-through;background:rgba(229,72,77,.1)}.tx ins{color:#1a7f3c;text-decoration:underline;background:rgba(46,158,79,.12)}.ls{list-style:none;display:grid;gap:4px}.ls li{display:flex;justify-content:space-between;align-items:center;gap:6px;font-size:11.5px}.ls span:first-child{color:var(--muted);min-width:0}.ls span:last-child{flex:none;white-space:nowrap}.ls button{height:24px;padding:0 9px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}.ls button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.mini{height:30px;padding:0 14px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:12px;font-weight:600;cursor:pointer}.mini:disabled{opacity:.4;cursor:default}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const S=['We ',[ 'are happy to inform','are pleased to say'],' you that the report ',['has been finished','is ready'],' and will be sent ',['in the near future','tomorrow'],'.'],CH=S.filter(x=>Array.isArray(x)),st=CH.map(()=>0);
const tx=document.getElementById('tx'),ls=document.getElementById('ls');let ci=0;
function up(){ci=0;tx.innerHTML=S.map(x=>{if(!Array.isArray(x))return x;const i=ci++;return st[i]===1?'<ins>'+x[1]+'</ins>':st[i]===2?x[0]:'<del>'+x[0]+'</del><ins>'+x[1]+'</ins>';}).join('');
ls.innerHTML=CH.map((c,i)=>'<li><span>'+(i+1)+'. '+c[1]+'</span><span><button type="button" data-i="'+i+'" data-v="1" aria-pressed="'+(st[i]===1)+'">Accept</button> <button type="button" data-i="'+i+'" data-v="2" aria-pressed="'+(st[i]===2)+'">Reject</button></span></li>').join('');
const a=st.filter(v=>v===1).length,r=st.filter(v=>v===2).length;document.getElementById('out').textContent=a+' accepted, '+r+' rejected, '+(st.length-a-r)+' pending.';}
ls.addEventListener('click',e=>{const b=e.target.closest('button');if(!b)return;const i=+b.dataset.i,v=+b.dataset.v;st[i]=st[i]===v?0:v;up();const nb=ls.querySelector('button[data-i="'+i+'"][data-v="'+v+'"]');if(nb)nb.focus();});
document.getElementById('aa').addEventListener('click',()=>{st.fill(1);up();});document.getElementById('ra').addEventListener('click',()=>{st.fill(2);up();});up();One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>AI Suggestion Diff — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.hd2{display:flex;justify-content:space-between;align-items:center;font-size:12.5px}.tx{border:1px solid var(--line);border-radius:10px;background:var(--surface);padding:8px 10px;font-size:12.5px;line-height:1.6}.tx del{color:#c62f2f;text-decoration:line-through;background:rgba(229,72,77,.1)}.tx ins{color:#1a7f3c;text-decoration:underline;background:rgba(46,158,79,.12)}.ls{list-style:none;display:grid;gap:4px}.ls li{display:flex;justify-content:space-between;align-items:center;gap:6px;font-size:11.5px}.ls span:first-child{color:var(--muted);min-width:0}.ls span:last-child{flex:none;white-space:nowrap}.ls button{height:24px;padding:0 9px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}.ls button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.mini{height:30px;padding:0 14px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:12px;font-weight:600;cursor:pointer}.mini:disabled{opacity:.4;cursor:default}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="hd2"><b>AI suggestions</b><span><button class="mini" id="aa" type="button">Accept all</button> <button class="mini" id="ra" type="button">Reject all</button></span></div><p class="tx" id="tx"></p><ul class="ls" id="ls"></ul><p class="out" id="out" role="status"></p></div>
</div>
<script>
const S=['We ',[ 'are happy to inform','are pleased to say'],' you that the report ',['has been finished','is ready'],' and will be sent ',['in the near future','tomorrow'],'.'],CH=S.filter(x=>Array.isArray(x)),st=CH.map(()=>0);
const tx=document.getElementById('tx'),ls=document.getElementById('ls');let ci=0;
function up(){ci=0;tx.innerHTML=S.map(x=>{if(!Array.isArray(x))return x;const i=ci++;return st[i]===1?'<ins>'+x[1]+'</ins>':st[i]===2?x[0]:'<del>'+x[0]+'</del><ins>'+x[1]+'</ins>';}).join('');
ls.innerHTML=CH.map((c,i)=>'<li><span>'+(i+1)+'. '+c[1]+'</span><span><button type="button" data-i="'+i+'" data-v="1" aria-pressed="'+(st[i]===1)+'">Accept</button> <button type="button" data-i="'+i+'" data-v="2" aria-pressed="'+(st[i]===2)+'">Reject</button></span></li>').join('');
const a=st.filter(v=>v===1).length,r=st.filter(v=>v===2).length;document.getElementById('out').textContent=a+' accepted, '+r+' rejected, '+(st.length-a-r)+' pending.';}
ls.addEventListener('click',e=>{const b=e.target.closest('button');if(!b)return;const i=+b.dataset.i,v=+b.dataset.v;st[i]=st[i]===v?0:v;up();const nb=ls.querySelector('button[data-i="'+i+'"][data-v="'+v+'"]');if(nb)nb.focus();});
document.getElementById('aa').addEventListener('click',()=>{st.fill(1);up();});document.getElementById('ra').addEventListener('click',()=>{st.fill(2);up();});up();
</script>
</body></html>