Let’s create a Glass Magic Navigation Menu using HTML, CSS, and JavaScript – a round glass button that opens six clear bubble icons in a circle, and when you pick one, that bubble flies smoothly into the center and shows its icon before the plus comes back.
- HTML: Create the radial menu wrapper, a list of six bubble buttons (Like, Chat, Share, Save, Alerts and Settings) with Phosphor icons, the center hub button and a small status toast.
- CSS: Style the clear glass bubbles with
backdrop-filter, layered gradients and a soft rainbow rim, place them in a circle usingrotate()andtranslate(), and add the float, jelly, blow and swap animations on top of a purple wave background. - JavaScript: Control opening and closing the menu, add name tags to each bubble, fly the picked bubble into the center, swap the hub icon, show a toast and bring the plus icon back after two seconds.
This project teaches how to build a glass radial navigation menu using HTML, CSS, and JavaScript by combining CSS custom properties for circular layout, backdrop-filter for real glass, staggered transitions with spring easing, and small JavaScript state handling for the fly-in effect.
HTML :
HTML: Creates the structure of the menu, including the six bubble buttons with their angle and order values, the Phosphor icons, the center hub button and the status toast.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Glass Magic Navigation Menu | Coding Stella</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@500;600&display=swap" rel="stylesheet" />
<script src="https://unpkg.com/@phosphor-icons/web@2.1.1"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="radial" id="radial">
<p class="toast" id="toast" role="status"></p>
<ul class="items">
<li>
<button class="item" style="--a: -90deg; --o: 0" aria-label="Like">
<span class="bubble"><i class="ph-duotone ph-heart"></i></span>
</button>
</li>
<li>
<button class="item" style="--a: -30deg; --o: 1" aria-label="Chat">
<span class="bubble"><i class="ph-duotone ph-chat-circle-dots"></i></span>
</button>
</li>
<li>
<button class="item" style="--a: 30deg; --o: 2" aria-label="Share">
<span class="bubble"><i class="ph-duotone ph-paper-plane-tilt"></i></span>
</button>
</li>
<li>
<button class="item" style="--a: 90deg; --o: 3" aria-label="Save">
<span class="bubble"><i class="ph-duotone ph-bookmark-simple"></i></span>
</button>
</li>
<li>
<button class="item" style="--a: 150deg; --o: 4" aria-label="Alerts">
<span class="bubble"><i class="ph-duotone ph-bell"></i></span>
</button>
</li>
<li>
<button class="item" style="--a: 210deg; --o: 5" aria-label="Settings">
<span class="bubble"><i class="ph-duotone ph-gear-six"></i></span>
</button>
</li>
</ul>
<button class="hub" id="hub" aria-expanded="false" aria-label="Open bubble menu">
<span class="hub-icon" id="hubIcon"><i class="ph-bold ph-plus"></i></span>
</button>
</div>
<script src="script.js"></script>
</body>
</html>
CSS :
CSS: Styles the glass bubbles and the hub, positions every bubble on a circle, and adds the staggered open and close motion, the floating and jelly effects, the name tags, the toast and the mobile and reduced motion rules.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--r: 150px;
--b: 78px;
--h: 92px;
--ease-spring: cubic-bezier(0.34, 1.6, 0.64, 1);
--ease-smooth: cubic-bezier(0.65, 0, 0.35, 1);
--film: conic-gradient(
rgba(160, 230, 255, 0.9),
rgba(255, 255, 255, 0) 18%,
rgba(200, 170, 255, 0.85) 34%,
rgba(255, 255, 255, 0) 50%,
rgba(170, 255, 220, 0.8) 66%,
rgba(255, 255, 255, 0) 82%,
rgba(160, 230, 255, 0.9)
);
}
body {
min-height: 100vh;
overflow: hidden;
font-family: "Poppins", sans-serif;
background: #1c1090 url("bg.svg") center / cover no-repeat;
}
.radial {
position: absolute;
top: 52%;
left: 50%;
}
.items {
list-style: none;
}
.item {
position: absolute;
width: var(--b);
height: var(--b);
margin: calc(var(--b) / -2) 0 0 calc(var(--b) / -2);
border: none;
border-radius: 50%;
background: none;
cursor: pointer;
visibility: hidden;
pointer-events: none;
transform: rotate(var(--a)) translate(0) rotate(calc(var(--a) * -1)) scale(0.1);
transition:
transform 0.85s cubic-bezier(0.5, -0.3, 0.4, 1) calc((5 - var(--o)) * 60ms),
visibility 0s linear calc((5 - var(--o)) * 60ms + 0.85s);
}
.radial.open .item {
visibility: visible;
pointer-events: auto;
transform: rotate(var(--a)) translate(var(--r)) rotate(calc(var(--a) * -1)) scale(1);
transition:
transform 0.7s cubic-bezier(0.2, 1.3, 0.4, 1) calc(var(--o) * 65ms),
visibility 0s;
}
.radial .item.picked {
z-index: 3;
visibility: visible;
transform: rotate(var(--a)) translate(0) rotate(calc(var(--a) * -1)) scale(1.18);
transition: transform 0.6s var(--ease-smooth);
}
.item:focus-visible {
outline: none;
}
.bubble {
--glass:
inset 0 0 0 1px rgba(255, 255, 255, 0.55),
inset 0 6px 10px rgba(255, 255, 255, 0.35),
inset 0 -8px 14px rgba(255, 255, 255, 0.22),
inset 0 0 22px rgba(255, 255, 255, 0.12),
0 12px 26px rgba(0, 20, 30, 0.22);
position: relative;
display: grid;
place-items: center;
width: 100%;
height: 100%;
border-radius: 50%;
background:
radial-gradient(ellipse 55% 22% at 50% 86%, rgba(255, 255, 255, 0.3), transparent 70%),
radial-gradient(
circle,
rgba(255, 255, 255, 0) 52%,
rgba(255, 255, 255, 0.12) 74%,
rgba(255, 255, 255, 0.4) 100%
);
-webkit-backdrop-filter: blur(2.5px) brightness(1.08) saturate(1.15);
backdrop-filter: blur(2.5px) brightness(1.08) saturate(1.15);
box-shadow: var(--glass);
opacity: 0;
animation: float 4.5s ease-in-out calc(var(--o) * -0.75s) infinite;
transition:
scale 0.35s var(--ease-spring),
opacity 0.5s ease calc((5 - var(--o)) * 60ms + 0.35s);
}
.radial.open .bubble {
opacity: 1;
animation:
jelly 0.9s ease calc(var(--o) * 65ms + 0.25s) both,
float 4.5s ease-in-out calc(var(--o) * -0.75s) infinite;
transition:
scale 0.35s var(--ease-spring),
opacity 0.25s ease calc(var(--o) * 65ms);
}
.item:hover .bubble {
scale: 1.1;
}
.item:focus-visible .bubble {
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8), var(--glass);
}
.bubble::before,
.hub::after {
content: "";
position: absolute;
border-radius: 50%;
background: radial-gradient(ellipse, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%);
}
.bubble::before {
top: 13%;
left: 20%;
width: 24%;
height: 15%;
transform: rotate(-35deg);
}
.bubble::after {
content: "";
position: absolute;
inset: 0;
padding: 2px;
border-radius: 50%;
background: var(--film);
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
filter: blur(0.5px);
opacity: 0.8;
animation: spin 9s linear infinite;
}
.bubble i,
.hub-icon i {
position: relative;
color: #fff;
filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}
.bubble i {
font-size: calc(var(--b) * 0.4);
}
.tip {
position: absolute;
bottom: calc(100% + 10px);
left: 50%;
padding: 5px 12px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.22);
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
color: #fff;
font-size: 12px;
font-weight: 500;
white-space: nowrap;
pointer-events: none;
opacity: 0;
transform: translate(-50%, 6px);
transition: opacity 0.25s ease, transform 0.25s ease;
}
.item:hover .tip,
.item:focus-visible .tip {
opacity: 1;
transform: translate(-50%, 0);
}
.item.picked .tip {
opacity: 0;
}
.hub {
position: absolute;
z-index: 2;
display: grid;
place-items: center;
width: var(--h);
height: var(--h);
margin: calc(var(--h) / -2) 0 0 calc(var(--h) / -2);
overflow: hidden;
border: none;
border-radius: 50%;
cursor: pointer;
background:
radial-gradient(ellipse 60% 25% at 50% 84%, rgba(255, 255, 255, 0.4), transparent 70%),
radial-gradient(
circle,
rgba(255, 255, 255, 0.1) 45%,
rgba(255, 255, 255, 0.28) 78%,
rgba(255, 255, 255, 0.55) 100%
);
-webkit-backdrop-filter: blur(14px) brightness(1.12) saturate(1.2);
backdrop-filter: blur(14px) brightness(1.12) saturate(1.2);
box-shadow:
inset 0 0 0 1.5px rgba(255, 255, 255, 0.7),
inset 0 8px 14px rgba(255, 255, 255, 0.4),
0 16px 34px rgba(0, 20, 30, 0.3);
transition: scale 0.3s var(--ease-spring);
}
.hub::before {
content: "";
position: absolute;
inset: 14%;
border-radius: 50%;
background: conic-gradient(
rgba(255, 255, 255, 0),
rgba(190, 240, 255, 0.55),
rgba(255, 255, 255, 0) 35%,
rgba(220, 200, 255, 0.45) 60%,
rgba(255, 255, 255, 0) 80%
);
filter: blur(6px);
animation: spin 5s linear infinite;
}
.hub::after {
top: 12%;
left: 22%;
width: 30%;
height: 16%;
transform: rotate(-30deg);
}
.hub:hover {
scale: 1.05;
}
.hub:focus-visible {
outline: 2px solid rgba(255, 255, 255, 0.7);
outline-offset: 4px;
}
.hub.blow {
animation: blow 0.55s ease;
}
.hub.absorb {
animation: absorb 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.hub-icon {
position: relative;
z-index: 1;
display: grid;
place-items: center;
font-size: calc(var(--h) * 0.4);
transition: transform 0.5s var(--ease-spring);
}
.radial.open .hub-icon {
transform: rotate(135deg);
}
.hub-icon.swap {
animation: swap 0.45s var(--ease-spring);
}
.toast {
position: absolute;
top: calc((var(--r) + var(--b) / 2 + 56px) * -1);
padding: 9px 20px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.2);
-webkit-backdrop-filter: blur(14px) saturate(1.3);
backdrop-filter: blur(14px) saturate(1.3);
box-shadow:
inset 0 0 0 1px rgba(255, 255, 255, 0.5),
0 10px 24px rgba(0, 20, 30, 0.2);
color: #fff;
font-size: 14px;
font-weight: 600;
white-space: nowrap;
pointer-events: none;
opacity: 0;
transform: translate(-50%, 10px);
transition:
opacity 0.3s ease,
transform 0.4s cubic-bezier(0.34, 1.5, 0.64, 1);
}
.toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
@keyframes float {
50% {
translate: 0 -7px;
}
}
@keyframes jelly {
25% {
scale: 1.14 0.86;
}
50% {
scale: 0.93 1.07;
}
75% {
scale: 1.03 0.97;
}
}
@keyframes blow {
30% {
scale: 1.12 0.88;
}
60% {
scale: 0.94 1.06;
}
}
@keyframes absorb {
40% {
scale: 1.1;
}
}
@keyframes swap {
from {
scale: 0.2;
opacity: 0;
}
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (max-width: 520px) {
:root {
--r: 118px;
--b: 62px;
--h: 78px;
}
}
@media (prefers-reduced-motion: reduce) {
.bubble,
.radial.open .bubble,
.bubble::after,
.hub::before {
animation: none;
}
}
JavaScript:
JavaScript: Handles opening and closing the menu, closing it with Escape or an outside click, flying the picked bubble into the center, swapping the hub icon and resetting it to the plus after two seconds.
const radial = document.getElementById("radial");
const hub = document.getElementById("hub");
const hubIcon = document.getElementById("hubIcon");
const toast = document.getElementById("toast");
const items = [...radial.querySelectorAll(".item")];
const PLUS = hubIcon.innerHTML;
const FLY = "0.6s cubic-bezier(0.65, 0, 0.35, 1)";
let icon = PLUS;
let busy = false;
let toastTimer;
let resetTimer;
function replay(el, className) {
el.classList.remove(className);
void el.offsetWidth;
el.classList.add(className);
}
function setHubIcon(html) {
icon = html;
hubIcon.innerHTML = html;
replay(hubIcon, "swap");
}
function setHubState(open, label) {
hub.setAttribute("aria-expanded", String(open));
hub.setAttribute("aria-label", label);
}
function openMenu() {
clearTimeout(resetTimer);
if (icon !== PLUS) setHubIcon(PLUS);
radial.classList.add("open");
setHubState(true, "Close bubble menu");
replay(hub, "blow");
}
function closeMenu() {
radial.classList.remove("open");
setHubState(false, "Open bubble menu");
}
function showToast(text) {
toast.textContent = text;
toast.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove("show"), 1600);
}
function pick(item) {
const bubble = item.querySelector(".bubble");
const label = item.getAttribute("aria-label");
busy = true;
bubble.style.translate = getComputedStyle(bubble).translate;
bubble.style.animation = "none";
void bubble.offsetWidth;
bubble.style.transition = `translate ${FLY}, scale 0.3s ease, opacity 0.22s ease 0.42s`;
bubble.style.translate = "0px 0px";
item.classList.add("picked");
closeMenu();
showToast(label);
setTimeout(() => {
setHubIcon(item.querySelector("i").outerHTML);
replay(hub, "absorb");
hub.setAttribute("aria-label", `${label} selected. Open bubble menu`);
}, 480);
setTimeout(() => {
item.classList.remove("picked");
bubble.removeAttribute("style");
busy = false;
}, 750);
resetTimer = setTimeout(() => {
setHubIcon(PLUS);
hub.setAttribute("aria-label", "Open bubble menu");
}, 2000);
}
items.forEach((item) => {
const tip = document.createElement("span");
tip.className = "tip";
tip.textContent = item.getAttribute("aria-label");
item.appendChild(tip);
item.addEventListener("click", () => {
if (!busy) pick(item);
});
});
hub.addEventListener("click", () => {
if (busy) return;
radial.classList.contains("open") ? closeMenu() : openMenu();
});
document.addEventListener("pointerdown", (e) => {
if (radial.classList.contains("open") && !radial.contains(e.target)) closeMenu();
});
document.addEventListener("keydown", (e) => {
if (e.key === "Escape") closeMenu();
});
This project demonstrates how HTML, CSS, and JavaScript can work together to turn a simple button into a playful glass navigation menu. You learned how to lay out items in a circle with CSS variables, make real see-through glass with backdrop-filter, and use a few lines of JavaScript to fly a bubble into the center and swap the icon. Try changing the icons, the radius or the colours to make it your own.
If your project has problems, don’t worry. Just click to download the source code and face your coding challenges with excitement. Have fun coding!
