-
Hover Expand Glassy Sidebar
HTML
CSS
JavaScript
Move your mouse over the icons to expand the full menu
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap'); :root { --white: #f5f8ff; --muted: #b9c9e3; --line: rgba(255, 255, 255, .2); --glass: rgba(255, 255, 255, .12); --blue: #1479ff } * { box-sizing: border-box } body { margin: 0; min-height: 100vh; font-family: Inter, Arial, sans-serif; color: var(--white); background: radial-gradient(ellipse at 15% 10%, #3d76b1 0, transparent 35%), radial-gradient(ellipse at 90% 20%, #124f9c 0, transparent 36%), linear-gradient(145deg, #102e55, #06152e 58%, #020914); display: flex; align-items: center; padding: 35px; overflow-x: hidden; scale:.8; } body:before { content: ""; position: fixed; width: 80vw; height: 80vw; border: 1px solid #80baff18; border-radius: 50%; left: -45vw; bottom: -58vw; pointer-events: none } .sidebar { width: 78px; height: min(850px, calc(100vh - 40px)); min-height: 650px; position: relative; z-index: 2; border: 1px solid rgba(205, 230, 255, .4); border-radius: 34px; padding: 17px 12px; overflow: hidden; background: linear-gradient(145deg, rgba(112, 181, 255, .27), rgba(12, 36, 73, .65) 48%, rgba(4, 14, 32, .82)); box-shadow: inset 0 1px 1px #ffffff35, 0 25px 70px #0008, 0 0 25px #3996ff25; backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); transition: width .38s cubic-bezier(.2, .8, .2, 1), padding .38s; } .sidebar:hover, .sidebar:focus-within { width: 350px; padding: 18px 15px } .sidebar:after { content: ""; position: absolute; right: 0; top: 0; width: 0; height: 100%; background: linear-gradient(180deg, #f4f8ff, #dceaff); border-radius: 0 33px 33px 0; opacity: 0; transition: width .35s, opacity .25s; z-index: -1 } .sidebar:hover:after, .sidebar:focus-within:after { width: 70px; opacity: 1 } .inner { height: 100%; width: 318px; display: flex; flex-direction: column; position: relative } .header { height: 62px; display: flex; align-items: center; gap: 13px; flex: none; margin: 0 3px 20px } .logo { height: 48px; width: 48px; min-width: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 25px; background: linear-gradient(145deg, #ffffff55, #3b83ca44); border: 1px solid #ffffff45; box-shadow: inset 0 2px 8px #ffffff35, 0 7px 18px #00102b77 } .brand { white-space: nowrap; opacity: 0; transform: translateX(-8px); transition: .22s; pointer-events: none } .brand strong { display: block; font-size: 17px } .brand small { display: block; color: #d0def4; font-size: 11px; margin-top: 4px } .sidebar:hover .brand, .sidebar:focus-within .brand { opacity: 1; transform: none } .collapse { margin-left: auto; width: 30px; height: 30px; border: 1px solid #ffffff2b; background: #ffffff20; color: white; border-radius: 50%; font-size: 20px; cursor: pointer; opacity: 0; transition: .2s } .sidebar:hover .collapse, .sidebar:focus-within .collapse { opacity: 1 } .search { height: 44px; display: flex; align-items: center; gap: 12px; margin: 0 2px 17px; padding: 0 14px; border-radius: 25px; background: #ffffff18; border: 1px solid #ffffff25; flex: none; overflow: hidden } .search-icon { font-size: 20px; min-width: 20px; text-align: center } .search input { width: 190px; min-width: 0; border: 0; outline: 0; background: transparent; color: white; font: 13px Inter; opacity: 0; transition: .2s } .search input::placeholder { color: #c4d3e9 } .sidebar:hover .search input, .sidebar:focus-within .search input { opacity: 1 } .shortcut { font-size: 10px; color: #d7e5f9; background: #ffffff20; padding: 5px 7px; border-radius: 10px; white-space: nowrap; opacity: 0 } .sidebar:hover .shortcut, .sidebar:focus-within .shortcut { opacity: 1 } nav { display: grid; gap: 8px; flex: none } .nav-group { display: grid; gap: 0 } .nav-item { height: 49px; width: 100%; display: flex; align-items: center; gap: 15px; padding: 0 13px; border-radius: 26px; border: 1px solid transparent; background: transparent; color: var(--white); font: 500 14px Inter; cursor: pointer; white-space: nowrap; transition: .2s } .nav-item:hover { background: #ffffff20; border-color: #ffffff20 } .nav-item.active { background: linear-gradient(100deg, #369cff, #0757eb); border-color: #91d2ff; box-shadow: 0 0 17px #1687ff66, inset 0 1px 0 #ffffff70 } .icon { width: 24px; min-width: 24px; text-align: center; font-size: 20px } .nav-label, .arrow { opacity: 0; transform: translateX(-5px); transition: .2s; pointer-events: none } .sidebar:hover .nav-label, .sidebar:focus-within .nav-label, .sidebar:hover .arrow, .sidebar:focus-within .arrow { opacity: 1; transform: none } .arrow { margin-left: auto } .submenu { display: grid; gap: 5px; max-height: 0; overflow: hidden; opacity: 0; visibility: hidden; padding-left: 42px; transition: max-height .28s ease, opacity .2s ease, margin .2s ease; margin: 0 } .nav-group:hover .submenu, .nav-group:focus-within .submenu { max-height: 180px; opacity: 1; visibility: visible; margin: 5px 0 7px } .submenu a { display: flex; align-items: center; min-height: 34px; padding: 7px 12px; border-radius: 13px; color: #d6e4f8; text-decoration: none; font-size: 12px; white-space: nowrap; border: 1px solid transparent; transition: background .2s, border-color .2s, color .2s } .submenu a:before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #91bfff; margin-right: 10px; flex: none } .submenu a:hover, .submenu a:focus { outline: 0; background: #ffffff20; border-color: #ffffff24; color: #fff } .projects { margin-top: 23px; display: grid; gap: 7px } .section-head { height: 28px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; color: #bdcce4; font-size: 10px; letter-spacing: 2px; font-weight: 700; white-space: nowrap } .section-head span { opacity: 0; transition: .2s } .sidebar:hover .section-head span, .sidebar:focus-within .section-head span { opacity: 1 } .add { width: 26px; height: 26px; border: 0; border-radius: 50%; background: #ffffff22; color: white; font-size: 19px; cursor: pointer; opacity: 0; pointer-events: none } .sidebar:hover .add, .sidebar:focus-within .add { opacity: 1; pointer-events: auto } .project { height: 40px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border-radius: 17px; background: #ffffff10; white-space: nowrap; overflow: hidden } .project-dot { width: 13px; height: 13px; min-width: 13px; border-radius: 5px; box-shadow: 0 0 12px currentColor } .yellow { background: #ffc34c; color: #ffc34c } .green { background: #35dfae; color: #35dfae } .pink { background: #f17cbd; color: #f17cbd } .project-name, .count { opacity: 0; transition: .2s } .project-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; flex: 1 } .count { font-size: 10px; background: #ffffff20; padding: 4px 8px; border-radius: 12px; color: #d9e6f8 } .sidebar:hover .project-name, .sidebar:focus-within .project-name, .sidebar:hover .count, .sidebar:focus-within .count { opacity: 1 } .bottom { margin-top: auto; display: grid; gap: 12px; padding-bottom: 1px } .pro { height: 58px; display: flex; align-items: center; gap: 10px; padding: 5px; border: 1px solid #ffffff30; border-radius: 20px; background: #ffffff18; overflow: hidden } .crown { width: 43px; height: 43px; min-width: 43px; border-radius: 50%; display: grid; place-items: center; border: 3px solid #ffd36a; color: #ffd36a; font-size: 20px; box-shadow: 0 0 14px #ffc64d70 } .pro-copy { font-size: 12px; font-weight: 700; white-space: nowrap; opacity: 0; transition: .2s } .pro-copy small { display: block; font-size: 10px; color: #c5d2e7; font-weight: 400; margin-top: 3px } .upgrade { border: 0; border-radius: 18px; background: linear-gradient(#ffe9a7, #ffbd37); padding: 9px 11px; color: #4c3300; font-weight: 700; white-space: nowrap; cursor: pointer; opacity: 0; transition: .2s } .sidebar:hover .pro-copy, .sidebar:focus-within .pro-copy, .sidebar:hover .upgrade, .sidebar:focus-within .upgrade { opacity: 1 } .profile { display: flex; align-items: center; gap: 11px; padding: 2px 5px; min-height: 52px; overflow: hidden } .avatar { height: 43px; width: 43px; min-width: 43px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(145deg, #ffe4c8, #ff9d62); color: #56351f; font-weight: 700; position: relative } .avatar:after { content: ""; position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; background: #22e4a5; border: 2px solid #17375f; border-radius: 50% } .profile-info { font-size: 12px; font-weight: 600; white-space: nowrap; opacity: 0; transition: .2s } .profile-info small { display: block; color: #b9c9e1; font-size: 10px; margin-top: 4px; font-weight: 400 } .more { margin-left: auto; color: #dce8f8; opacity: 0 } .sidebar:hover .profile-info, .sidebar:focus-within .profile-info, .sidebar:hover .more, .sidebar:focus-within .more { opacity: 1 } .rail-actions { position: absolute; top: 17px; right: 10px; width: 48px; display: flex; align-items: center; flex-direction: column; gap: 12px; opacity: 0; pointer-events: none; transition: .2s } .sidebar:hover .rail-actions, .sidebar:focus-within .rail-actions { opacity: 1; pointer-events: auto } .rail-btn { width: 42px; height: 42px; border: 0; border-radius: 16px; background: #ffffffc9; color: #193967; font-size: 19px; box-shadow: 0 5px 13px #15396635; cursor: pointer } .rail-btn.primary { background: #1769dc; color: white } .rail-spacer { height: 260px } .hint { position: fixed; left: 50%; bottom: 25px; transform: translateX(-50%); font-size: 12px; color: #d5e4f8; opacity: .7; white-space: nowrap } .toast { position: fixed; bottom: 55px; left: 50%; transform: translateX(-50%) translateY(12px); padding: 10px 17px; border: 1px solid #ffffff35; border-radius: 25px; background: #102b52; color: white; font-size: 12px; opacity: 0; transition: .2s; pointer-events: none; z-index: 5 } .toast.show { opacity: 1; transform: translateX(-50%) } @media(max-width:500px) { body { padding: 12px } .sidebar { height: calc(100vh - 24px); min-height: 610px } .sidebar:hover, .sidebar:focus-within { width: min(350px, calc(100vw - 24px)) } .inner { width: 318px } .hint { bottom: 8px; font-size: 10px } } @media(hover:none) { .sidebar { width: min(350px, calc(100vw - 24px)) } .brand, .collapse, .search input, .shortcut, .nav-label, .arrow, .section-head span, .add, .project-name, .count, .pro-copy, .upgrade, .profile-info, .more { opacity: 1; transform: none; pointer-events: auto } .rail-actions { opacity: 1; pointer-events: auto } .sidebar:after { width: 70px; opacity: 1 } }
const sidebar = document.getElementById('sidebar'), toast = document.getElementById('toast'); let timer; function notify(s) { toast.textContent = s; toast.classList.add('show'); clearTimeout(timer); timer = setTimeout(() => toast.classList.remove('show'), 1500) } document.querySelectorAll('.nav-item').forEach(b => b.addEventListener('click', () => { document.querySelectorAll('.nav-item').forEach(x => x.classList.remove('active')); b.classList.add('active'); notify(b.dataset.name + ' selected') })); document.querySelectorAll('[data-message]').forEach(b => b.addEventListener('click', () => notify(b.dataset.message))); document.querySelectorAll('.submenu a').forEach(a => a.addEventListener('click', e => { e.preventDefault(); notify(a.textContent + ' opened') })); document.getElementById('add').addEventListener('click', () => { const n = prompt('Project name?'); if (!n || !n.trim()) return; const row = document.createElement('div'); row.className = 'project'; row.innerHTML = '
0
'; row.querySelector('.project-name').textContent = n.trim(); document.querySelector('.projects').append(row); notify('Project added') }); document.getElementById('upgrade').addEventListener('click', () => notify('Upgrade selected')); document.getElementById('search').addEventListener('input', e => { const q = e.target.value.toLowerCase(); document.querySelectorAll('.nav-item').forEach(b => b.style.display = b.dataset.name.toLowerCase().includes(q) ? 'flex' : 'none') }); document.addEventListener('keydown', e => { if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') { e.preventDefault(); sidebar.classList.add('keyboard-open'); document.getElementById('search').focus() } });
Live Preview