Neumorphic Interactive Liquid Button
Home
Snippets
Neumorphic Interactive Liquid Button
HTML
CSS
JS
<div class="container"> <button class="liquid-btn" id="btn">Interactive Element</button> </div>
:root { --bg: #e0e5ec; --shadow-light: #ffffff; --shadow-dark: #a3b1c6; --accent: #00CFA9; } body { background-color: var(--bg); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; font-family: 'Segoe UI', sans-serif; } .container { position: relative; } .liquid-btn { padding: 20px 40px; font-size: 18px; font-weight: 600; color: #54595F; background: var(--bg); border: none; border-radius: 50px; cursor: pointer; outline: none; transition: transform 0.2s ease-out; box-shadow: 9px 9px 16px var(--shadow-dark), -9px -9px 16px var(--shadow-light); position: relative; overflow: hidden; z-index: 1; } .liquid-btn:active { box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light); transform: scale(0.98); } .ripple { position: absolute; background: var(--accent); transform: translate(-50%, -50%); pointer-events: none; border-radius: 50%; animation: blow 0.8s linear; opacity: 0.5; z-index: -1; } @keyframes blow { from { width: 0; height: 0; opacity: 0.5; } to { width: 400px; height: 400px; opacity: 0; } }
const btn = document.getElementById('btn'); btn.addEventListener('mousemove', (e) => { const rect = btn.getBoundingClientRect(); const x = e.clientX - rect.left - rect.width / 2; const y = e.clientY - rect.top - rect.height / 2; btn.style.transform = `translate(${x * 0.3}px, ${y * 0.5}px)`; }); btn.addEventListener('mouseleave', () => { btn.style.transform = `translate(0px, 0px)`; }); btn.addEventListener('click', function(e) { let x = e.clientX - e.target.offsetLeft; let y = e.clientY - e.target.offsetTop; let ripple = document.createElement('span'); ripple.classList.add('ripple'); ripple.style.left = x + 'px'; ripple.style.top = y + 'px'; this.appendChild(ripple); setTimeout(() => ripple.remove(), 800); });
Ad #1
Ad #2
Scroll to Top