Cause and Effect Chain
A four-step chain lights up one step at a time; switch to a failure case to see where it breaks and what never happens.
AI prompt
Clean explainer diagram of a four-step chain left to right: Tap Pay, Bank approves, Receipt sent, Order confirmed, each in a rounded card joined by arrows, the first two steps filled in blue with green check marks, the third step outlined in red with a cross and the label Server error, the last step greyed out and dashed, a caption under the chain reading Without the receipt the order is never confirmed, light theme, flat vector style. Negative: gradients, clutter, text errors. Reduced motion: static diagram.About this pattern
Definition
Cause-and-effect explainers show how one event triggers the next. Lighting steps in order, with arrows that fill as the signal passes, makes the sequence easy to follow. Showing a broken case, where the chain stops and later steps stay dark, explains what failure looks like and why it matters.
When to use it
- Keep the chain to three to five steps with short labels.
- Highlight one step at a time and fill the arrow before the next step lights.
- In the failure case, mark the broken step clearly and leave later steps unlit.
- Give a one-line caption that explains each step in plain words.
What the controls do
- Play, Step and Reset, with two scenarios.
Motion & timing
- Each step takes about 700ms.
- Reduced motion: no autoplay; use Step.
Tips & variations
- Offer a Step button as well as Play so people control the pace.
- Do not rely on colour alone: mark the broken step with an icon and text.
Code of this live preview
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Scenario"><button data-p="0" aria-pressed="true">Everything works</button><button data-p="1" aria-pressed="false">A step fails</button></div><ol class="ch" id="ch"></ol><p class="out" id="out" role="status"></p><div class="two"><button class="mini" id="pl" type="button">Play</button><button class="mini" id="st" type="button">Step</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}
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}
.ch{list-style:none;display:flex;align-items:stretch;gap:0;margin:2px 0}.ch li{flex:1;display:flex;align-items:center;min-width:0}.nd{flex:1;min-width:0;border:1.5px solid #d6d6d2;background:#fff;border-radius:10px;padding:8px 4px;text-align:center;font-size:11px;font-weight:600;color:#8a8a86;transition:all .25s;min-height:52px;display:grid;place-items:center;align-content:center;gap:2px}.nd i{font-style:normal;font-size:14px;height:16px}.nd.on{background:#2f6bff;border-color:#2f6bff;color:#fff}.nd.bad{background:#fff;border-color:#d92d20;color:#d92d20}.nd.off{border-style:dashed;opacity:.55}.ar{width:18px;height:3px;background:#d6d6d2;position:relative;flex:none;overflow:hidden}.ar::after{content:"";position:absolute;inset:0;background:#2f6bff;transform:scaleX(0);transform-origin:left;transition:transform .3s}.ar.on::after{transform:scaleX(1)}.out{font-size:12.5px;min-height:34px;margin:0}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}.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){.nd,.ar::after{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const S=[['Tap Pay','You press the pay button.'],['Bank approves','The bank checks and approves the payment.'],['Receipt sent','The shop sends your receipt.'],['Order confirmed','Your order is confirmed.']],ch=document.getElementById('ch'),out=document.getElementById('out'),pl=document.getElementById('pl'),bs=[...document.querySelectorAll('#pre button')],calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let p=0,n=0,tm=null;const FAIL=2;
ch.innerHTML=S.map((s,i)=>'<li><div class="nd" id="n'+i+'"><i></i>'+s[0]+'</div>'+(i<S.length-1?'<span class="ar" id="a'+i+'"></span>':'')+'</li>').join('');
function draw(){S.forEach((s,i)=>{const e=document.getElementById('n'+i),ic=e.firstChild;e.className='nd';ic.textContent='';const broken=p===1&&i===FAIL,after=p===1&&i>FAIL;if(i<n){if(broken){e.classList.add('bad');ic.textContent='\u2715';}else if(!after){e.classList.add('on');ic.textContent='\u2713';}}else if(i===n&&false){}
if(p===1&&n>FAIL&&after)e.classList.add('off');const a=document.getElementById('a'+i);if(a)a.classList.toggle('on',i<n-1&&!(p===1&&i>=FAIL));});
out.textContent=n===0?'Press Play or Step.':p===1&&n>FAIL?'Step 3 failed, so step 4 never happens: the order is not confirmed.':n>=S.length?'All steps completed: the order is confirmed.':S[n-1][1];bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
function step(){if(n>=S.length||(p===1&&n>FAIL))return false;n++;draw();return !(n>=S.length||(p===1&&n>FAIL));}
function play(){clearTimeout(tm);pl.textContent='Play';if(n>=S.length||(p===1&&n>FAIL))n=0;draw();(function go(){const more=step();if(more){pl.textContent='Playing\u2026';tm=setTimeout(go,700);}else pl.textContent='Replay';})();}
function reset(){clearTimeout(tm);n=0;pl.textContent='Play';draw();}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;reset();}));pl.addEventListener('click',()=>{if(calm)step();else play();});document.getElementById('st').addEventListener('click',()=>{clearTimeout(tm);if(n>=S.length||(p===1&&n>FAIL))reset();else step();});draw();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>Cause and Effect Chain — 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}
.ch{list-style:none;display:flex;align-items:stretch;gap:0;margin:2px 0}.ch li{flex:1;display:flex;align-items:center;min-width:0}.nd{flex:1;min-width:0;border:1.5px solid #d6d6d2;background:#fff;border-radius:10px;padding:8px 4px;text-align:center;font-size:11px;font-weight:600;color:#8a8a86;transition:all .25s;min-height:52px;display:grid;place-items:center;align-content:center;gap:2px}.nd i{font-style:normal;font-size:14px;height:16px}.nd.on{background:#2f6bff;border-color:#2f6bff;color:#fff}.nd.bad{background:#fff;border-color:#d92d20;color:#d92d20}.nd.off{border-style:dashed;opacity:.55}.ar{width:18px;height:3px;background:#d6d6d2;position:relative;flex:none;overflow:hidden}.ar::after{content:"";position:absolute;inset:0;background:#2f6bff;transform:scaleX(0);transform-origin:left;transition:transform .3s}.ar.on::after{transform:scaleX(1)}.out{font-size:12.5px;min-height:34px;margin:0}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}.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){.nd,.ar::after{transition: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="Scenario"><button data-p="0" aria-pressed="true">Everything works</button><button data-p="1" aria-pressed="false">A step fails</button></div><ol class="ch" id="ch"></ol><p class="out" id="out" role="status"></p><div class="two"><button class="mini" id="pl" type="button">Play</button><button class="mini" id="st" type="button">Step</button></div></div>
</div>
<script>
const S=[['Tap Pay','You press the pay button.'],['Bank approves','The bank checks and approves the payment.'],['Receipt sent','The shop sends your receipt.'],['Order confirmed','Your order is confirmed.']],ch=document.getElementById('ch'),out=document.getElementById('out'),pl=document.getElementById('pl'),bs=[...document.querySelectorAll('#pre button')],calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let p=0,n=0,tm=null;const FAIL=2;
ch.innerHTML=S.map((s,i)=>'<li><div class="nd" id="n'+i+'"><i></i>'+s[0]+'</div>'+(i<S.length-1?'<span class="ar" id="a'+i+'"></span>':'')+'</li>').join('');
function draw(){S.forEach((s,i)=>{const e=document.getElementById('n'+i),ic=e.firstChild;e.className='nd';ic.textContent='';const broken=p===1&&i===FAIL,after=p===1&&i>FAIL;if(i<n){if(broken){e.classList.add('bad');ic.textContent='\u2715';}else if(!after){e.classList.add('on');ic.textContent='\u2713';}}else if(i===n&&false){}
if(p===1&&n>FAIL&&after)e.classList.add('off');const a=document.getElementById('a'+i);if(a)a.classList.toggle('on',i<n-1&&!(p===1&&i>=FAIL));});
out.textContent=n===0?'Press Play or Step.':p===1&&n>FAIL?'Step 3 failed, so step 4 never happens: the order is not confirmed.':n>=S.length?'All steps completed: the order is confirmed.':S[n-1][1];bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
function step(){if(n>=S.length||(p===1&&n>FAIL))return false;n++;draw();return !(n>=S.length||(p===1&&n>FAIL));}
function play(){clearTimeout(tm);pl.textContent='Play';if(n>=S.length||(p===1&&n>FAIL))n=0;draw();(function go(){const more=step();if(more){pl.textContent='Playing\u2026';tm=setTimeout(go,700);}else pl.textContent='Replay';})();}
function reset(){clearTimeout(tm);n=0;pl.textContent='Play';draw();}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;reset();}));pl.addEventListener('click',()=>{if(calm)step();else play();});document.getElementById('st').addEventListener('click',()=>{clearTimeout(tm);if(n>=S.length||(p===1&&n>FAIL))reset();else step();});draw();
</script>
</body></html>