Of course. As a front-end expert, I'll create a sophisticated and beautiful glassmorphic floating tab bar. This demo will not only showcase the "frosted glass" aesthetic but also incorporate a "progressive blur" effect that intensifies as the user scrolls down the page.
This implementation uses modern web technologies for a clean, performant, and maintainable result.
Key Features:
Floating & Centered: The tab bar is detached from the page edges, floating near the bottom of the viewport.
True Glassmorphism: Utilizes backdrop-filter to create a realistic frosted glass effect, blurring the content behind it.
Progressive Blur: The blur intensity is dynamically linked to the page scroll position via JavaScript, creating a subtle and engaging micro-interaction.
Slick Active Indicator: A "pill" smoothly slides to highlight the currently active tab.
Performant Animations: Leverages CSS transitions and requestAnimationFrame for smooth, jank-free animations.
Accessible & Semantic: Uses a nav element for the tab bar and proper <a> tags for navigation items. Icons are paired with text labels.
Modern Code: Employs CSS Custom Properties (variables) for easy theming and dynamic updates from JavaScript.
Live Demo
Here's a live, interactive demo on CodePen. Scroll the page to see the progressive blur in action!
The Glass Effect (CSS): The core of the glassmorphism is achieved with background and backdrop-filter.
background: rgba(255, 255, 255, 0.15);: A semi-transparent white background provides the base layer of the "glass".
backdrop-filter: blur(var(--blur-amount));: This is the magic. It blurs whatever is behind the element. We use a CSS variable --blur-amount so we can control it with JavaScript.
A subtle border and box-shadow complete the effect, lifting the element off the page.
The Sliding Indicator (CSS & JS):
An ::after pseudo-element on the <ul> acts as the sliding "pill" indicator.
Its position is controlled by transform: translateX(var(--indicator-offset));.
When a tab is clicked, JavaScript calculates the offsetLeft of the clicked item and updates the --indicator-offset CSS variable on the <ul> element. CSS transition handles the smooth sliding animation automatically.
The Progressive Blur (JS):
A scroll event listener is attached to the window.
To ensure performance, we use requestAnimationFrame. This tells the browser, "I want to perform an animation and I'd like you to call me back right before the next repaint." This is much more efficient than updating the style directly in the scroll event handler.
In the animation frame, we:
Calculate the user's scroll progress (from 0 to 1).
Map this progress to a blur range (e.g., from a minimum of 5px to a maximum of 20px).
Update the --blur-amount CSS variable on the tab bar element.
The Code
Here is the complete, self-contained code for the demo.
HTML (index.html)
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Glassmorphic Floating Tab Bar</title>
<link rel="stylesheet" href="style.css">
<!-- Using Font Awesome for icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
<header>
<h1>Glassmorphic Tab Bar</h1>
<p>Scroll down to see the progressive blur effect.</p>
</header>
<main>
<section>
<h2>Page Content Section 1</h2>
<p>Lorem ipsum dolor sit amet...</p>
<p>Pellentesque habitant morbi tristique...</p>
</section>
<section>
<h2>Page Content Section 2</h2>
<p>Phasellus viverra nulla ut metus...</p>
<p>Etiam rhoncus. Maecenas tempus...</p>
</section>
<section>
<h2>Page Content Section 3</h2>
<p>Aenean vulputate eleifend tellus...</p>
<p>Nam eget dui. Etiam rhoncus...</p>
</section>
<section>
<h2>Page Content Section 4</h2>
<p>Donec vitae sapien ut libero...</p>
<p>Nullam quis ante. Etiam sit amet...</p>
</section>
</main>
<nav class="tab-bar">
<ul class="tab-list">
<li class="tab-item active" data-index="0">
<a href="#home">
<i class="fas fa-home"></i>
<span class="tab-label">Home</span>
</a>
</li>
<li class="tab-item" data-index="1">
<a href="#search">
<i class="fas fa-search"></i>
<span class="tab-label">Search</span>
</a>
</li>
<li class="tab-item" data-index="2">
<a href="#activity">
<i class="fas fa-heart"></i>
<span class="tab-label">Activity</span>
</a>
</li>
<li class="tab-item" data-index="3">
<a href="#profile">
<i class="fas fa-user"></i>
<span class="tab-label">Profile</span>
</a>
</li>
</ul>
</nav>
<script src="script.js"></script>
</body>
</html>