AI Thinking States
Three ways to show that an assistant is working (dots, shimmer, steps) with a Stop button and a finished answer.
AI prompt
Clean chat interface screenshot on a light background: a user message bubble on the right reading Summarise this report, below it on the left an assistant row with a small avatar and three soft grey dots in a pill, the middle dot slightly larger, a small Stop button with a square icon to the right, flat design, rounded corners, minimal and calm. Variants: a shimmering label Searching the web, and a checklist of three steps with the first two ticked. Negative: spinner, heavy shadows, gradients, text errors, clutter. Reduced motion: static dots.About this pattern
Definition
Between sending a prompt and the first word of the answer, the interface has to say something is happening. Dots are the lightest signal, a shimmering label says what is happening, and a short step list shows real progress for longer jobs.
Purpose & UX principles
- Use dots for waits under two seconds, a shimmer label for two to ten, and steps beyond that.
- Always offer Stop while the assistant is working.
- Replace the indicator with the answer in the same place so the layout does not jump.
Interaction states
- Three style buttons, a Send button that runs the demo and a Stop button.
Motion specification
- Dots bounce at 1.2s; the shimmer sweeps at 1.6s; each step ticks every 700ms.
- Reduced motion: dots and shimmer are static, steps still tick as text.
Responsive behaviour
- Announce status changes politely to screen readers; do not repeat the same message.
- Keep the label specific: Searching the web is better than Thinking.
Code
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Style"><button data-p="0" aria-pressed="true">Dots</button><button data-p="1" aria-pressed="false">Shimmer</button><button data-p="2" aria-pressed="false">Steps</button></div><div class="ch"><div class="um">Summarise this report</div><div class="as" id="as" aria-live="polite"></div></div><div class="ac"><button class="mini" id="go" type="button">Send</button><button class="mini" id="st" type="button" disabled>Stop</button></div></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}
.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}
.ch{display:grid;gap:8px;border:1px solid var(--line);border-radius:12px;background:var(--surface);padding:10px;min-height:128px;align-content:start}.um{justify-self:end;background:#171717;color:#fff;border-radius:14px 14px 4px 14px;padding:6px 11px;font-size:12px}
.as{font-size:12.5px;color:var(--text);line-height:1.5;min-height:56px}.dt{display:inline-flex;gap:4px;padding:8px 11px;background:var(--pv);border-radius:99px}.dt i{width:6px;height:6px;border-radius:50%;background:#777;animation:bn 1.2s infinite}.dt i:nth-child(2){animation-delay:.15s}.dt i:nth-child(3){animation-delay:.3s}
@keyframes bn{0%,60%,100%{transform:none;opacity:.5}30%{transform:translateY(-4px);opacity:1}}
.sh{background:linear-gradient(90deg,#999 20%,#171717 50%,#999 80%) 0 0/200% 100%;-webkit-background-clip:text;background-clip:text;color:transparent;-webkit-text-fill-color:transparent;font-weight:600;animation:sw 1.6s linear infinite}@keyframes sw{to{background-position:-200% 0}}
.stp{list-style:none;display:grid;gap:3px}.stp li{color:var(--muted)}.stp li.d{color:var(--text)}.stp li.d::before{content:"\2713 ";color:#2a9d62}.stp li.c::before{content:"\2022 ";}
.ac{display:flex;gap:8px}.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){.dt i,.sh{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const as=document.getElementById('as'),go=document.getElementById('go'),st=document.getElementById('st'),bs=[...document.querySelectorAll('#pre button')];let p=0,tm=[],run=false;
const S=['Reading the report','Finding key figures','Writing the summary'],ANS='Revenue grew 12% year on year, driven by subscriptions. Costs were flat, so margin improved to 31%.';
function clear(){tm.forEach(clearTimeout);tm=[];}
function idle(){as.textContent='';}
function show(i){as.innerHTML=p===0?'<span class="dt" aria-label="Assistant is thinking"><i></i><i></i><i></i></span>':p===1?'<span class="sh">Searching the web\u2026</span>':'<ul class="stp">'+S.map((s,k)=>'<li class="'+(k<i?'d':k===i?'c':'')+'">'+s+(k===i?'\u2026':'')+'</li>').join('')+'</ul>';}
function end(txt){run=false;go.disabled=false;st.disabled=true;as.textContent=txt;}
function start(){clear();run=true;go.disabled=true;st.disabled=false;show(0);if(p===2){S.forEach((s,k)=>tm.push(setTimeout(()=>show(k+1>2?3:k+1),(k+1)*700)));}
tm.push(setTimeout(()=>end(ANS),p===2?2300:2000));}
go.addEventListener('click',start);st.addEventListener('click',()=>{clear();end('Stopped.');});
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;bs.forEach(k=>k.setAttribute('aria-pressed',String(k===b)));clear();end('');idle();start();}));start();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 Thinking States — 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}}
.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}
.ch{display:grid;gap:8px;border:1px solid var(--line);border-radius:12px;background:var(--surface);padding:10px;min-height:128px;align-content:start}.um{justify-self:end;background:#171717;color:#fff;border-radius:14px 14px 4px 14px;padding:6px 11px;font-size:12px}
.as{font-size:12.5px;color:var(--text);line-height:1.5;min-height:56px}.dt{display:inline-flex;gap:4px;padding:8px 11px;background:var(--pv);border-radius:99px}.dt i{width:6px;height:6px;border-radius:50%;background:#777;animation:bn 1.2s infinite}.dt i:nth-child(2){animation-delay:.15s}.dt i:nth-child(3){animation-delay:.3s}
@keyframes bn{0%,60%,100%{transform:none;opacity:.5}30%{transform:translateY(-4px);opacity:1}}
.sh{background:linear-gradient(90deg,#999 20%,#171717 50%,#999 80%) 0 0/200% 100%;-webkit-background-clip:text;background-clip:text;color:transparent;-webkit-text-fill-color:transparent;font-weight:600;animation:sw 1.6s linear infinite}@keyframes sw{to{background-position:-200% 0}}
.stp{list-style:none;display:grid;gap:3px}.stp li{color:var(--muted)}.stp li.d{color:var(--text)}.stp li.d::before{content:"\2713 ";color:#2a9d62}.stp li.c::before{content:"\2022 ";}
.ac{display:flex;gap:8px}.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){.dt i,.sh{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Style"><button data-p="0" aria-pressed="true">Dots</button><button data-p="1" aria-pressed="false">Shimmer</button><button data-p="2" aria-pressed="false">Steps</button></div><div class="ch"><div class="um">Summarise this report</div><div class="as" id="as" aria-live="polite"></div></div><div class="ac"><button class="mini" id="go" type="button">Send</button><button class="mini" id="st" type="button" disabled>Stop</button></div></div>
</div>
<script>
const as=document.getElementById('as'),go=document.getElementById('go'),st=document.getElementById('st'),bs=[...document.querySelectorAll('#pre button')];let p=0,tm=[],run=false;
const S=['Reading the report','Finding key figures','Writing the summary'],ANS='Revenue grew 12% year on year, driven by subscriptions. Costs were flat, so margin improved to 31%.';
function clear(){tm.forEach(clearTimeout);tm=[];}
function idle(){as.textContent='';}
function show(i){as.innerHTML=p===0?'<span class="dt" aria-label="Assistant is thinking"><i></i><i></i><i></i></span>':p===1?'<span class="sh">Searching the web\u2026</span>':'<ul class="stp">'+S.map((s,k)=>'<li class="'+(k<i?'d':k===i?'c':'')+'">'+s+(k===i?'\u2026':'')+'</li>').join('')+'</ul>';}
function end(txt){run=false;go.disabled=false;st.disabled=true;as.textContent=txt;}
function start(){clear();run=true;go.disabled=true;st.disabled=false;show(0);if(p===2){S.forEach((s,k)=>tm.push(setTimeout(()=>show(k+1>2?3:k+1),(k+1)*700)));}
tm.push(setTimeout(()=>end(ANS),p===2?2300:2000));}
go.addEventListener('click',start);st.addEventListener('click',()=>{clear();end('Stopped.');});
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;bs.forEach(k=>k.setAttribute('aria-pressed',String(k===b)));clear();end('');idle();start();}));start();
</script>
</body></html>