Share Menu Button
A share icon button that opens a menu with copy link and social targets.
Preview and code
index.html
<div class='sm'><button type='button' id='smb' aria-label='Share'><svg width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'><circle cx='18' cy='5' r='2.6'/><circle cx='6' cy='12' r='2.6'/><circle cx='18' cy='19' r='2.6'/><path d='M8.3 10.8l7.4-4.2M8.3 13.2l7.4 4.2'/></svg></button><ul id='smm' role='menu'><li id='smc'>Copy link</li><li>Email</li><li>Message</li></ul></div>
styles.css
.sm{position:relative;display:inline-block;margin:auto;font-family:Inter,Arial,sans-serif;color:#111}.sm>button{display:grid;place-items:center;width:38px;height:38px;border:1px solid #efefef;border-radius:11px;background:#fff;color:#444;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.05)}.sm>button:hover{color:#111}.sm ul{display:none;position:absolute;left:50%;top:100%;z-index:5;min-width:150px;margin:8px 0 0 -75px;padding:5px;list-style:none;background:#fff;border:1px solid #e5e5e5;border-radius:12px;box-shadow:0 12px 30px rgba(0,0,0,.14)}.sm ul.on{display:block;animation:sm-in .15s ease}.sm li{padding:8px 11px;font-size:13.5px;border-radius:8px;cursor:pointer}.sm li:hover{background:#f4f4f4}@keyframes sm-in{from{opacity:0;transform:translateY(-4px)}}
script.js
const b=document.getElementById('smb'),m=document.getElementById('smm'),c=document.getElementById('smc');b.addEventListener('click',()=>m.classList.toggle('on'));c.addEventListener('click',e=>{e.stopPropagation();try{navigator.clipboard&&navigator.clipboard.writeText(location.href)}catch(x){}c.textContent='Copied!';setTimeout(()=>{c.textContent='Copy link';m.classList.remove('on')},900)});m.addEventListener('click',e=>{if(e.target!==c)m.classList.remove('on')});document.addEventListener('mousedown',e=>{if(!b.parentNode.contains(e.target))m.classList.remove('on')});
About
An icon button that opens a share popover with Copy link (shows Copied feedback), Email and Message options.