AI Response Actions
Copy, thumbs up and down with follow-up reasons, and Regenerate under an AI answer.
AI prompt
Design the action bar under an AI chat answer. Answer text: "Use a 12-column grid with 24 pixel gutters on desktop." Below it, four icon buttons with tooltips and aria-labels: Copy, Good response, Bad response, Regenerate. Copy copies the text and swaps its icon to a check for 1.5 seconds. Good and Bad toggle (aria-pressed) and are mutually exclusive; choosing Bad reveals chips "Inaccurate", "Too long", "Not helpful" and choosing a chip replaces them with "Thanks for the feedback". Regenerate shows a shimmering placeholder for about a second and then a different answer. Light minimal style, 32 pixel round icon buttons, subtle hover, prefers-reduced-motion fallback. Plain HTML, CSS and JavaScript with inline SVG icons.About this pattern
Definition
Response actions are the small toolbar beneath an AI answer. They let people copy it, rate it and ask for another version, and they feed quality signals back to the product.
Purpose & UX principles
- Copy, Good, Bad and Regenerate cover the four things people do most after reading an answer.
- A thumbs-down should ask a one-tap reason (Inaccurate, Too long, Not helpful) without blocking the conversation.
- Confirm every action quietly (checkmark, "Thanks") and keep icon buttons labelled for assistive tech.
Interaction states
- Default, copied (checkmark 1.5s), thumbs pressed (only one at a time), reasons shown after thumbs-down, thanks, regenerating (shimmer) and new answer.
Motion specification
- Copy checkmark pops in 150ms; reasons slide down 160ms; regenerate shows a shimmer for 900ms then fades in the new text.
- Reduced motion: no shimmer or slide, only the text swap.
Responsive behaviour
- Icon buttons are at least 32px square with 4px gaps; labels appear on hover or focus.
- On phones show the toolbar permanently, not on hover.
Code
<div class="bx"><div class="ans" id="ans">Use a 12-column grid with 24 pixel gutters on desktop.</div><div class="bar" role="toolbar" aria-label="Response actions"><button id="cp" type="button" aria-label="Copy" title="Copy">⧉</button><button id="up" type="button" aria-label="Good response" aria-pressed="false" title="Good response">👍</button><button id="dn" type="button" aria-label="Bad response" aria-pressed="false" title="Bad response">👎</button><button id="rg" type="button" aria-label="Regenerate" title="Regenerate">↻</button></div><div class="rs" id="rs" hidden><span>What went wrong?</span><button type="button">Inaccurate</button><button type="button">Too long</button><button type="button">Not helpful</button></div><p class="th" id="th" aria-live="polite"></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}
.bx{width:min(320px,100%);display:grid;gap:8px}
.ans{padding:12px 14px;border-radius:12px;background:var(--surface);border:1px solid var(--line);font-size:13.5px;line-height:1.5;min-height:52px}
.ans.load{color:transparent;background:linear-gradient(90deg,#ececE8 25%,#f6f6f3 50%,#ececE8 75%) 0 0/200% 100%;animation:sh 1s linear infinite;border-color:var(--line)}
@keyframes sh{to{background-position:-200% 0}}
.bar{display:flex;gap:4px}.bar button{width:34px;height:34px;border-radius:50%;border:0;background:none;font-size:15px;cursor:pointer;color:#555}.bar button:hover{background:#e8e8e4}.bar button[aria-pressed=true]{background:var(--text);color:#fff;filter:none}
.rs{display:flex;flex-wrap:wrap;gap:5px;align-items:center;font-size:12px;color:var(--muted);animation:dn .16s ease-out}.rs[hidden]{display:none}
@keyframes dn{from{opacity:0;transform:translateY(-4px)}}
.rs button{height:26px;padding:0 10px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:12px;cursor:pointer}
.th{font-size:12px;color:var(--muted);min-height:16px}
button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){.ans.load{animation:none}.rs{animation:none}}const $=id=>document.getElementById(id),ans=$('ans'),cp=$('cp'),up=$('up'),dn=$('dn'),rg=$('rg'),rs=$('rs'),th=$('th'),A=['Use a 12-column grid with 24 pixel gutters on desktop.','Start from 4 columns on phones, 8 on tablets and 12 on desktop, with consistent gutters.','A 12-column grid divides cleanly into halves, thirds and quarters, which is why it is so common.'];let n=0,txt=A[0];
function press(b){[up,dn].forEach(x=>x.setAttribute('aria-pressed',String(x===b&&x.getAttribute('aria-pressed')!=='true')));}
cp.addEventListener('click',()=>{const done=()=>{cp.textContent='✓';th.textContent='Copied';setTimeout(()=>{cp.textContent='⧉';th.textContent='';},1500);};if(navigator.clipboard)navigator.clipboard.writeText(ans.textContent).then(done,done);else done();});
up.addEventListener('click',()=>{press(up);rs.hidden=true;th.textContent=up.getAttribute('aria-pressed')==='true'?'Thanks for the feedback':'';});
dn.addEventListener('click',()=>{press(dn);const on=dn.getAttribute('aria-pressed')==='true';rs.hidden=!on;th.textContent='';});
rs.addEventListener('click',e=>{if(e.target.tagName==='BUTTON'){rs.hidden=true;th.textContent='Thanks for the feedback';}});
rg.addEventListener('click',()=>{up.setAttribute('aria-pressed','false');dn.setAttribute('aria-pressed','false');rs.hidden=true;th.textContent='';const red=matchMedia('(prefers-reduced-motion: reduce)').matches;if(!red){ans.classList.add('load');}ans.setAttribute('aria-busy','true');setTimeout(()=>{n=(n+1)%A.length;ans.classList.remove('load');ans.textContent=A[n];ans.setAttribute('aria-busy','false');},red?0:900);});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 Response Actions — 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}}
.bx{width:min(320px,100%);display:grid;gap:8px}
.ans{padding:12px 14px;border-radius:12px;background:var(--surface);border:1px solid var(--line);font-size:13.5px;line-height:1.5;min-height:52px}
.ans.load{color:transparent;background:linear-gradient(90deg,#ececE8 25%,#f6f6f3 50%,#ececE8 75%) 0 0/200% 100%;animation:sh 1s linear infinite;border-color:var(--line)}
@keyframes sh{to{background-position:-200% 0}}
.bar{display:flex;gap:4px}.bar button{width:34px;height:34px;border-radius:50%;border:0;background:none;font-size:15px;cursor:pointer;color:#555}.bar button:hover{background:#e8e8e4}.bar button[aria-pressed=true]{background:var(--text);color:#fff;filter:none}
.rs{display:flex;flex-wrap:wrap;gap:5px;align-items:center;font-size:12px;color:var(--muted);animation:dn .16s ease-out}.rs[hidden]{display:none}
@keyframes dn{from{opacity:0;transform:translateY(-4px)}}
.rs button{height:26px;padding:0 10px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:12px;cursor:pointer}
.th{font-size:12px;color:var(--muted);min-height:16px}
button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){.ans.load{animation:none}.rs{animation:none}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="ans" id="ans">Use a 12-column grid with 24 pixel gutters on desktop.</div><div class="bar" role="toolbar" aria-label="Response actions"><button id="cp" type="button" aria-label="Copy" title="Copy">⧉</button><button id="up" type="button" aria-label="Good response" aria-pressed="false" title="Good response">👍</button><button id="dn" type="button" aria-label="Bad response" aria-pressed="false" title="Bad response">👎</button><button id="rg" type="button" aria-label="Regenerate" title="Regenerate">↻</button></div><div class="rs" id="rs" hidden><span>What went wrong?</span><button type="button">Inaccurate</button><button type="button">Too long</button><button type="button">Not helpful</button></div><p class="th" id="th" aria-live="polite"></p></div>
</div>
<script>
const $=id=>document.getElementById(id),ans=$('ans'),cp=$('cp'),up=$('up'),dn=$('dn'),rg=$('rg'),rs=$('rs'),th=$('th'),A=['Use a 12-column grid with 24 pixel gutters on desktop.','Start from 4 columns on phones, 8 on tablets and 12 on desktop, with consistent gutters.','A 12-column grid divides cleanly into halves, thirds and quarters, which is why it is so common.'];let n=0,txt=A[0];
function press(b){[up,dn].forEach(x=>x.setAttribute('aria-pressed',String(x===b&&x.getAttribute('aria-pressed')!=='true')));}
cp.addEventListener('click',()=>{const done=()=>{cp.textContent='✓';th.textContent='Copied';setTimeout(()=>{cp.textContent='⧉';th.textContent='';},1500);};if(navigator.clipboard)navigator.clipboard.writeText(ans.textContent).then(done,done);else done();});
up.addEventListener('click',()=>{press(up);rs.hidden=true;th.textContent=up.getAttribute('aria-pressed')==='true'?'Thanks for the feedback':'';});
dn.addEventListener('click',()=>{press(dn);const on=dn.getAttribute('aria-pressed')==='true';rs.hidden=!on;th.textContent='';});
rs.addEventListener('click',e=>{if(e.target.tagName==='BUTTON'){rs.hidden=true;th.textContent='Thanks for the feedback';}});
rg.addEventListener('click',()=>{up.setAttribute('aria-pressed','false');dn.setAttribute('aria-pressed','false');rs.hidden=true;th.textContent='';const red=matchMedia('(prefers-reduced-motion: reduce)').matches;if(!red){ans.classList.add('load');}ans.setAttribute('aria-busy','true');setTimeout(()=>{n=(n+1)%A.length;ans.classList.remove('load');ans.textContent=A[n];ans.setAttribute('aria-busy','false');},red?0:900);});
</script>
</body></html>