Glass Navigation
A glass navigation bar that floats over the backdrop: 16 px blur, pill links that light up on hover and on keyboard focus, current page in purple. CSS only.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Glassmorphism has 47 effects, including 6 free. Explore the category →
3 usage examples



How it works
The bar is a <nav class="glass-nav-bar">, 48 px tall, absolutely positioned 20 px from the top and from both sides of .glass-nav-scene: it touches no edge, hence the look of a floating pill. Its glass takes four declarations — 8% white, backdrop-filter: blur(16px), a 10% white border, 12 px corners. Behind it, the demo scene (360 × 200 px, plum to midnight-blue gradient) carries two .glass-nav-bg-orb orbs, a 200 px purple one and a 150 px cyan one, blurred at 50 px: they are what tints the glass.
The brand sits on the left (.glass-nav-logo, weight 800), three <button class="glass-nav-link"> on the right, 12 px in 70% white. On hover a link turns full white on a 10% white pill with 8 px corners, in 0.3 s. Keyboard focus gives exactly the same state, ringed by a 2 px lavender outline. The entry for the current page carries .glass-nav-link--active — a 30% purple pill with a 40% edge — and aria-current="page".
There is not one line of JavaScript: the active class is written in the HTML, by your template or your router, and nothing moves it on click. The bar does not react to scrolling either, and the code ships no collapsed menu for small screens: at 320 px wide the brand and the three links still fit inside the bar, but they touch. The links can be <a href> elements with no CSS change — the underline is already removed.
Accessibility
- Keyboard: measured in Chromium, Firefox and WebKit, Tab moves focus to each link, which takes the hover pill plus a
#c4b5fdoutline offset by 2 px. In Safari, Tab only stops on buttons and links when “Press Tab to highlight each item” is ticked; otherwise use Option + Tab. - What Enter and Space do: they activate the
<button>, but the code you buy attaches no action to it. To go from page to page, swap the buttons for<a href>; keep buttons only when a script of yours changes the view without leaving the page. - Screen readers: the bar is a real
<nav>named byaria-label(“Main navigation”) and the active entry is announced thanks toaria-current="page". If you move the active class, move the attribute with it. - Touch: there is no hover on a touch screen. Measured in mobile emulation, the tapped link keeps its white pill until the next tap — harmless when it leads to another page. Links are 28 px tall: raise their
paddingto 12 px to get close to the advised 44 px. - Contrast, measured on the bar's real background: resting links between 4.8:1 (over the purple orb) and 8.0:1; hovered or active link between 8.0:1 and 14.8:1. Over a bright photo the 8% white veil no longer protects the text: darken the glass. Nothing moves continuously, only the colour changes in 0.3 s.
Browser compatibility
Three engines measured under Playwright (Chromium, Firefox, WebKit): same computed values for the glass (blur(16px)), hover and focus; the frosting itself could only be looked at in Chromium (the scenes on this page): automated captures of Firefox and WebKit do not paint it, even on a minimal test block. Real Safari: not verified. Minimum versions from MDN: backdrop-filter since Chrome 76, Edge 79, Firefox 103; Safari reads it from version 9 as -webkit-backdrop-filter, which the code also declares, and unprefixed from 18. :focus-visible lands with Chrome 86 and Safari 15.4; its rule is written apart from the hover rule, so an older browser keeps the hover and its default focus ring.
Without backdrop-filter the bar stays an 8% white veil with a hairline border: the backdrop is no longer frosted but the links, their hover and the active pill work as they are. If that backdrop is a sharp photo, give the bar a denser fill inside @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))), for instance rgba(20, 18, 40, .72).
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0303-root">
<div class="glass-nav-scene">
<div class="glass-nav-bg-orb glass-nav-bg-orb--1"></div>
<div class="glass-nav-bg-orb glass-nav-bg-orb--2"></div>
<nav class="glass-nav-bar" aria-label="…">
<span class="glass-nav-logo">…</span>
<div class="glass-nav-links">
<button type="button" class="glass-nav-link glass-nav-link--active" aria-current="page">…</button>
<button type="button" class="glass-nav-link">…</button>
<button type="button" class="glass-nav-link">…</button>
</div>
</nav>
<div class="glass-nav-content">
<h4>…</h4>
<p>…</p>
</div>
</div>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Glass of the bar (CSS — .glass-nav-bar { background; backdrop-filter }) |
8% white, 16 px blur, 10% white border | Change the blur value on both lines, -webkit-backdrop-filter and backdrop-filter. 24 px drowns a photo completely; 8 px keeps shapes recognisable. Over a bright backdrop, swap the white for a dark fill, rgba(15, 15, 30, .45). |
Place and shape (CSS — top / left / right: 20px, height: 48px, border-radius: 12px) |
20 px off the edges, 48 px tall, 12 px corners | top: auto; bottom: 20px makes it a tab bar; border-radius: 999px a capsule; left: 0; right: 0; top: 0; border-radius: 0 a full-width bar. The bar is placed relative to .glass-nav-scene, which must stay position: relative. |
Current page (CSS — .glass-nav-link--active) |
fill rgba(139,92,246,.3), border rgba(139,92,246,.4) |
Put your brand colour in those two values. One entry only carries the class, together with aria-current="page"; each page's HTML decides which. |
Hover and focus (CSS — .glass-nav-link:hover, :focus-visible, transition: .3s) |
white text, 10% white pill, 2 px #c4b5fd outline for the keyboard |
The two rules are separate: edit them together to keep the same state for mouse and keyboard. Do not remove the outline, it is the only focus cue on the glass. |
Links (HTML — <button> or <a href>, CSS padding: 6px 12px, font-size: .75rem) |
three 12 px buttons, 28 px tall | Add or remove entries freely: the bar right-aligns them 4 px apart. Past four or five links under 400 px wide, plan your own collapsed menu — the code does not provide one. |
Backdrop (CSS — .glass-nav-scene, .glass-nav-bg-orb--1, --2) |
360 × 200 px scene, purple #7c3aed and cyan #0891b2 orbs blurred at 50 px |
The orbs are only there to colour the demo's glass. On your page, delete them and set the bar over your own image or video; size the scene to your header. |
FAQ
spans. Glass Navigation has no script and its blur never changes; it floats clear of the edges and takes care of what the other leaves out: real buttons reachable by keyboard, a hover state, a focus state, a current page announced to screen readers. Pick Frosted Glass Navbar for a header that must react to scrolling, Glass Navigation for a menu, a tab bar or a selector you can drop anywhere.glass-nav-link--active class is written in the HTML. On a classic site, each page renders its menu with the class on its own entry. In a single-page app three lines are enough: on click, take the class and aria-current off the old link and put them on the new one — which is what the tab bar and the speed selector in the examples do.position: absolute inside its scene and leaves with it. Take the <nav> out of the scene and switch it to position: fixed (or sticky inside your header), with a z-index above the content. The blur then applies to everything scrolling underneath. Reserve the bar's height plus its 20 px margin at the top of the page, or it will cover your first heading.