Funnel Chart
Four funnel stages with step and overall conversion; hover or focus a stage to read its details.
AI prompt
Create a four-stage conversion funnel: Visitors 10,000, Sign-ups 3,200, Trials 1,100, Paid 420. Each stage is a horizontal bar centred in the row with width proportional to its count, near-black for the focused stage and mid-grey for the others, stage name and count inside or beside the bar. Between stages show the step conversion as a small grey percentage chip (32%, 34%, 38%) and mark the biggest drop-off in red text. A detail line below shows the hovered or focused stage: "Trials: 11% of all visitors, 34% of sign-ups". Stages are focusable buttons with aria-describedby on the detail line. Bars animate in with an 80 millisecond stagger; prefers-reduced-motion shows them instantly. Plain HTML, CSS and JavaScript.About this pattern
Definition
A funnel chart shows how a count shrinks through ordered stages. Each bar's width shows the number that reached that stage, and the gap between bars shows the drop-off.
Purpose & UX principles
- Use for processes where people progress step by step: visit, sign up, trial, paid.
- Show two numbers per stage: conversion from the previous step and from the very first step.
- Order stages logically and keep labels short; highlight the biggest drop-off to guide action.
Interaction states
- Default, hover or focus on a stage (detail text and highlight), biggest drop-off marked.
Motion specification
- Bars grow from the left over 500ms with a 80ms stagger on load; hover highlight 120ms.
- Reduced motion: bars appear at full size.
Responsive behaviour
- Bars scale to the container width; on narrow screens keep labels above the bars and move percentages into the detail line.
- Each stage is focusable so keyboard users get the same details.
Code
<div class="bx"><div class="fn" id="fn" role="list"></div><p class="out" id="out" 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:10px}
.fn{display:grid;gap:4px}
.st{display:grid;justify-items:center;gap:3px}
.bar{width:var(--w);min-width:132px;gap:10px;white-space:nowrap;height:34px;border-radius:8px;border:0;background:#c9c9c4;color:#171717;display:flex;justify-content:space-between;align-items:center;padding:0 12px;font-size:12.5px;cursor:pointer;transform-origin:50% 50%;animation:gr .5s ease-out both;animation-delay:calc(var(--i) * 80ms);transition:background .12s,color .12s}
@keyframes gr{from{transform:scaleX(.2);opacity:0}}
.bar b{font-weight:600}.bar span{font-variant-numeric:tabular-nums}
.bar:hover,.bar:focus-visible,.bar[aria-current=true]{background:#171717;color:#fff}
.ch{font-size:11px;color:var(--muted);margin:1px 0}.ch.hot{color:var(--danger);font-weight:700}
.out{font-size:12.5px;color:var(--muted);min-height:36px;line-height:1.4}.out b{color:var(--text)}
button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){.bar{animation:none;transition:none}}const S=[['Visitors',10000],['Sign-ups',3200],['Trials',1100],['Paid',420]],fn=document.getElementById('fn'),out=document.getElementById('out'),bars=[];
let worst=1,wv=1;S.forEach((s,i)=>{if(i&&s[1]/S[i-1][1]<wv){wv=s[1]/S[i-1][1];worst=i;}});
S.forEach((s,i)=>{if(i){const c=document.createElement('div');c.className='ch'+(i===worst?' hot':'');c.textContent='↓ '+Math.round(s[1]/S[i-1][1]*100)+'% continue'+(i===worst?' · biggest drop':'');fn.append(c);}
const w=document.createElement('div');w.className='st';w.setAttribute('role','listitem');const b=document.createElement('button');b.type='button';b.className='bar';b.style.setProperty('--w',(s[1]/S[0][1]*100)+'%');b.style.setProperty('--i',i);b.innerHTML='<b>'+s[0]+'</b><span>'+s[1].toLocaleString('en-US')+'</span>';
const show=()=>{bars.forEach(x=>x.removeAttribute('aria-current'));b.setAttribute('aria-current','true');out.innerHTML='<b>'+s[0]+'</b>: '+(s[1]/S[0][1]*100).toFixed(s[1]/S[0][1]<.1?1:0)+'% of all visitors'+(i?', '+Math.round(s[1]/S[i-1][1]*100)+'% of '+S[i-1][0]:'')+'.';};
b.addEventListener('pointerenter',show);b.addEventListener('focus',show);b.addEventListener('click',show);bars.push(b);w.append(b);fn.append(w);});
bars[0].setAttribute('aria-current','true');out.innerHTML='<b>Visitors</b>: 100% of all visitors. Hover or focus a stage.';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>Funnel Chart — 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:10px}
.fn{display:grid;gap:4px}
.st{display:grid;justify-items:center;gap:3px}
.bar{width:var(--w);min-width:132px;gap:10px;white-space:nowrap;height:34px;border-radius:8px;border:0;background:#c9c9c4;color:#171717;display:flex;justify-content:space-between;align-items:center;padding:0 12px;font-size:12.5px;cursor:pointer;transform-origin:50% 50%;animation:gr .5s ease-out both;animation-delay:calc(var(--i) * 80ms);transition:background .12s,color .12s}
@keyframes gr{from{transform:scaleX(.2);opacity:0}}
.bar b{font-weight:600}.bar span{font-variant-numeric:tabular-nums}
.bar:hover,.bar:focus-visible,.bar[aria-current=true]{background:#171717;color:#fff}
.ch{font-size:11px;color:var(--muted);margin:1px 0}.ch.hot{color:var(--danger);font-weight:700}
.out{font-size:12.5px;color:var(--muted);min-height:36px;line-height:1.4}.out b{color:var(--text)}
button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){.bar{animation:none;transition:none}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="fn" id="fn" role="list"></div><p class="out" id="out" aria-live="polite"></p></div>
</div>
<script>
const S=[['Visitors',10000],['Sign-ups',3200],['Trials',1100],['Paid',420]],fn=document.getElementById('fn'),out=document.getElementById('out'),bars=[];
let worst=1,wv=1;S.forEach((s,i)=>{if(i&&s[1]/S[i-1][1]<wv){wv=s[1]/S[i-1][1];worst=i;}});
S.forEach((s,i)=>{if(i){const c=document.createElement('div');c.className='ch'+(i===worst?' hot':'');c.textContent='↓ '+Math.round(s[1]/S[i-1][1]*100)+'% continue'+(i===worst?' · biggest drop':'');fn.append(c);}
const w=document.createElement('div');w.className='st';w.setAttribute('role','listitem');const b=document.createElement('button');b.type='button';b.className='bar';b.style.setProperty('--w',(s[1]/S[0][1]*100)+'%');b.style.setProperty('--i',i);b.innerHTML='<b>'+s[0]+'</b><span>'+s[1].toLocaleString('en-US')+'</span>';
const show=()=>{bars.forEach(x=>x.removeAttribute('aria-current'));b.setAttribute('aria-current','true');out.innerHTML='<b>'+s[0]+'</b>: '+(s[1]/S[0][1]*100).toFixed(s[1]/S[0][1]<.1?1:0)+'% of all visitors'+(i?', '+Math.round(s[1]/S[i-1][1]*100)+'% of '+S[i-1][0]:'')+'.';};
b.addEventListener('pointerenter',show);b.addEventListener('focus',show);b.addEventListener('click',show);bars.push(b);w.append(b);fn.append(w);});
bars[0].setAttribute('aria-current','true');out.innerHTML='<b>Visitors</b>: 100% of all visitors. Hover or focus a stage.';
</script>
</body></html>