Toggletip Info Bubble
An info button that opens a small bubble on click, unlike a hover-only tooltip, so it works with touch and keyboard.
AI prompt
Clean UI mockup of a form row with the label Plan and a small round grey i icon button next to it, a small dark rounded bubble with a tiny arrow opened above the icon reading Billing is monthly and you can cancel any time, the icon highlighted with a thin ring, light theme, flat modern style, plenty of space. Variant: the same bubble flipped below the icon near the top edge. Negative: heavy shadows, clutter, text errors, device frames. Reduced motion: static design.About this pattern
Definition
A tooltip appears on hover and disappears when the pointer leaves, which fails on touch and for keyboard users. A toggletip is opened on purpose: an info button toggles a short bubble that stays until dismissed with a second click, Escape or a click elsewhere. It suits help text that is more than a label.
Purpose & UX principles
- Use a real button with aria-expanded and an accessible name like More information about Plan.
- Show the bubble next to the button and connect it with aria-describedby or place it right after in the DOM.
- Close on Escape, outside click and a second activation, and keep focus on the button.
- Keep the text short; for long content use a popover or dialog.
Interaction states
- Three info buttons in a form; click, tap, press Enter or Space.
Motion specification
- The bubble fades in over 120ms.
- Reduced motion: no fade.
Responsive behaviour
- Do not put essential information only in the bubble; it must be reachable but not required to proceed.
- Make the bubble flip when near an edge so it is not clipped.
Code
<div class="bx"><div class="fm" id="fm"></div><p class="out" id="out"></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}
.fm{display:grid;gap:14px;padding-top:34px}.row{display:flex;align-items:center;gap:6px;font-size:13px;position:relative}.row b{font-weight:600;min-width:70px}.row .sel{flex:1;height:30px;border:1px solid var(--line);border-radius:8px;background:var(--surface);display:flex;align-items:center;padding:0 10px;color:var(--muted);font-size:12px}.ib{width:22px;height:22px;border-radius:50%;border:1.5px solid #8a8a86;color:#555;font:700 12px/1 system-ui;display:grid;place-items:center}.ib[aria-expanded=true]{background:#171717;color:#fff;border-color:#171717}.tip{position:absolute;left:78px;bottom:calc(100% + 8px);width:190px;background:#262629;color:#fff;font-size:12px;line-height:1.4;border-radius:8px;padding:8px 10px;z-index:4;animation:fi .12s}.tip.dn{bottom:auto;top:calc(100% + 8px)}.tip::after{content:"";position:absolute;left:14px;top:100%;border:6px solid transparent;border-top-color:#262629}.tip.dn::after{top:auto;bottom:100%;border-top-color:transparent;border-bottom-color:#262629}@keyframes fi{from{opacity:0}}.out{font-size:12px;color:var(--muted);min-height:16px}@media (prefers-reduced-motion:reduce){.tip{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const R=[['Plan','Billing is monthly and you can cancel any time.'],['Seats','Each seat is one person who can edit. Viewers are free.'],['Region','Data is stored in the region you pick and cannot be moved later.']],fm=document.getElementById('fm'),out=document.getElementById('out');let open=null;
fm.innerHTML=R.map((r,i)=>'<div class="row"><b>'+r[0]+'</b><span class="sel">Choose\u2026</span><button type="button" class="ib" data-i="'+i+'" aria-expanded="false" aria-label="More information about '+r[0]+'">i</button></div>').join('');
function close(){if(open===null)return;const b=fm.querySelector('.ib[data-i="'+open+'"]');b.setAttribute('aria-expanded','false');b.removeAttribute('aria-describedby');const t=fm.querySelector('.tip');if(t)t.remove();open=null;}
function show(i){close();const b=fm.querySelector('.ib[data-i="'+i+'"]'),row=b.parentNode,t=document.createElement('div');t.className='tip';t.id='tip';t.setAttribute('role','status');t.textContent=R[i][1];row.appendChild(t);if(row.getBoundingClientRect().top-t.offsetHeight-8<0)t.classList.add('dn');b.setAttribute('aria-expanded','true');b.setAttribute('aria-describedby','tip');open=i;out.textContent='Open: press Escape or click again to close.';}
fm.addEventListener('click',e=>{const b=e.target.closest('.ib');if(!b)return;const i=+b.dataset.i;if(open===i){close();out.textContent='';}else show(i);e.stopPropagation();});
document.addEventListener('click',e=>{if(open!==null&&!e.target.closest('.tip')){close();out.textContent='';}});document.addEventListener('keydown',e=>{if(e.key==='Escape'&&open!==null){const b=fm.querySelector('.ib[data-i="'+open+'"]');close();b.focus();out.textContent='';}});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>Toggletip Info Bubble — 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}
.fm{display:grid;gap:14px;padding-top:34px}.row{display:flex;align-items:center;gap:6px;font-size:13px;position:relative}.row b{font-weight:600;min-width:70px}.row .sel{flex:1;height:30px;border:1px solid var(--line);border-radius:8px;background:var(--surface);display:flex;align-items:center;padding:0 10px;color:var(--muted);font-size:12px}.ib{width:22px;height:22px;border-radius:50%;border:1.5px solid #8a8a86;color:#555;font:700 12px/1 system-ui;display:grid;place-items:center}.ib[aria-expanded=true]{background:#171717;color:#fff;border-color:#171717}.tip{position:absolute;left:78px;bottom:calc(100% + 8px);width:190px;background:#262629;color:#fff;font-size:12px;line-height:1.4;border-radius:8px;padding:8px 10px;z-index:4;animation:fi .12s}.tip.dn{bottom:auto;top:calc(100% + 8px)}.tip::after{content:"";position:absolute;left:14px;top:100%;border:6px solid transparent;border-top-color:#262629}.tip.dn::after{top:auto;bottom:100%;border-top-color:transparent;border-bottom-color:#262629}@keyframes fi{from{opacity:0}}.out{font-size:12px;color:var(--muted);min-height:16px}@media (prefers-reduced-motion:reduce){.tip{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="fm" id="fm"></div><p class="out" id="out"></p></div>
</div>
<script>
const R=[['Plan','Billing is monthly and you can cancel any time.'],['Seats','Each seat is one person who can edit. Viewers are free.'],['Region','Data is stored in the region you pick and cannot be moved later.']],fm=document.getElementById('fm'),out=document.getElementById('out');let open=null;
fm.innerHTML=R.map((r,i)=>'<div class="row"><b>'+r[0]+'</b><span class="sel">Choose\u2026</span><button type="button" class="ib" data-i="'+i+'" aria-expanded="false" aria-label="More information about '+r[0]+'">i</button></div>').join('');
function close(){if(open===null)return;const b=fm.querySelector('.ib[data-i="'+open+'"]');b.setAttribute('aria-expanded','false');b.removeAttribute('aria-describedby');const t=fm.querySelector('.tip');if(t)t.remove();open=null;}
function show(i){close();const b=fm.querySelector('.ib[data-i="'+i+'"]'),row=b.parentNode,t=document.createElement('div');t.className='tip';t.id='tip';t.setAttribute('role','status');t.textContent=R[i][1];row.appendChild(t);if(row.getBoundingClientRect().top-t.offsetHeight-8<0)t.classList.add('dn');b.setAttribute('aria-expanded','true');b.setAttribute('aria-describedby','tip');open=i;out.textContent='Open: press Escape or click again to close.';}
fm.addEventListener('click',e=>{const b=e.target.closest('.ib');if(!b)return;const i=+b.dataset.i;if(open===i){close();out.textContent='';}else show(i);e.stopPropagation();});
document.addEventListener('click',e=>{if(open!==null&&!e.target.closest('.tip')){close();out.textContent='';}});document.addEventListener('keydown',e=>{if(e.key==='Escape'&&open!==null){const b=fm.querySelector('.ib[data-i="'+open+'"]');close();b.focus();out.textContent='';}});
</script>
</body></html>