React Glassmorphism Navbar with a Frosted Blur on Scroll
ProA sticky header that starts invisible over your hero and turns into frosted glass the moment the page moves: a translucent white or near black fill, a heavy backdrop blur, a hairline border, and a red underline that slides in under the active link.
Glass that appears only when it is needed
Navbar with Frosted Glass is a React and Tailwind CSS glassmorphism navbar: a sticky header with a semi transparent background and a CSS backdrop-filter blur, so the page shows through it softly as you scroll. It works in Next.js or any React app and switches between light and dark glass with your theme.
Glass effects fail when they sit on a flat colour, because there is nothing behind them to blur. This block avoids that by staying fully transparent at the top of the page, where it sits over the hero, and only frosting once there is content scrolling underneath. If your layout needs the glass from the first frame, a single prop forces it on.
The link rail is centred and appears from 1024px up. Below that a three line icon morphs into a cross and opens a drawer with the links as large tap targets and the primary button underneath.
Parts of the glass header
Frosted state
After 8px of scroll the bar takes bg-white/90 with backdrop-blur-xl in light mode, or a 82 percent near black with backdrop-blur-2xl in dark mode, plus a one pixel bottom border.
Active underline
Each link owns a 1.5px bar that scales in from the left over 380ms. It stays drawn under the active link and previews under any link you hover.
Prefix matching
A link can carry a match string, so Docs stays highlighted on every page that starts with /docs rather than only on its exact href.
Action cluster
A text Sign in link and a solid accent button. The button takes extra classes through primaryCtaClassName, which is how you swap the colour without touching the file.
Morphing menu icon
Three CSS bars rotate and fade into an X when the drawer opens. No icon package is involved.
Where frosted glass works
Use it when
- Your hero has a photo, gradient or animated background that the blur can pick up as the page scrolls.
- You want the header to disappear into the hero at load and still stay readable over long pages.
- You need a simple flat menu of four to six links with a clear active state.
- You want the accent colour of the button and underline to follow your brand through class overrides.
Skip it when
- You need dropdown menus. This header has none.
- Your pages are plain white with dark text, where the frosted state looks almost identical to a solid bar and costs a blur for nothing.
- You expect it to route out of the box. The links are buttons that only change a local highlight, as explained below.
- Low end Android devices are a large share of your traffic. Backdrop blur repaints whenever the content behind it moves.
Make the links navigate, then brand it
This is the one change you must make. In the shipped file every rail item and every drawer item is a button that sets an internal activePath state, which starts at /components, and nothing navigates. Replace each button with your router's Link, keep the underline span inside it, and compute active from usePathname() instead of state. The isActive helper already handles the match prefix, so it can stay as it is.
With routing in place, pass your own links and calls to action, set brandName and logo, and recolour with primaryCtaClassName and indicatorClassName, for example bg-emerald-600 hover:bg-emerald-700 on the button and bg-emerald-500 on the underline. Delete the demo block with the Build bold headline at the bottom of the component.
npx wensity@latest add navbar-with-frosted-glass --type block
import { GlassNavbar } from "@/components/wensity/blocks/navbar-with-frosted-glass";export function Header() {return (<GlassNavbarbrandName="Northwind"links={[{ label: "Product", href: "/product" },{ label: "Customers", href: "/customers" },{ label: "Docs", href: "/docs", match: "/docs" },{ label: "Pricing", href: "/pricing" },]}primaryCta={{ label: "Start a trial", href: "/signup" }}secondaryCta={{ label: "Sign in", href: "/login" }}primaryCtaClassName="bg-emerald-600 border-emerald-500/30 hover:bg-emerald-700"indicatorClassName="bg-emerald-500"/>);}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
links | { label: string; href: string; match?: string }[] | - | Rail entries. match keeps an entry active for every path under a prefix, which suits sections like docs or blog. |
alwaysFrosted | boolean | false | Starts in the glass state and skips the scroll listener. Use it on pages without a hero, where a transparent bar would sit on bare content. |
primaryCtaClassName | string | - | Merged onto both copies of the main button. Background, border and hover colour overrides go here. |
indicatorClassName | string | - | Merged onto the underline. Pass a background class to match the button. |
primaryCta | { label: string; href: string } | Get started | The solid button, also shown at the end of the drawer. |
secondaryCta | { label: string; href: string } | Sign in | A plain text link. It hides below 640px and is not repeated in the drawer, so add it there if signing in matters on phones. |
What to check before it ships
Routing is a placeholder
Buttons that set state are fine for a demo and wrong for a site: search engines do not follow them and users cannot open them in a new tab. Swapping them for anchors is required, not optional.
Cost of the blur
backdrop-filter is GPU work that repeats whenever content scrolls beneath the bar. It is cheap on modern laptops and phones, and the transparent top state means it costs nothing until the first scroll.
Drawer semantics
The menu button has an Open or Close label but no aria-expanded or aria-controls. Add both so assistive technology announces the drawer state.
Reduced motion
Only the drawer height and the underline animate, both briefly. Neither checks prefers-reduced-motion, which is a small fix with MotionConfig and a motion-reduce:transition-none class.
Accent tokens
The default button and underline use the chili accent classes from the Wensity theme. If your project does not define them, pass your own colours through the two class props.
Block details
- Category
- Navbars
- Renders
- JavaScript animation. Paints first, then animates
- Theme
- Follows the site theme in light and dark
- Dependencies
clsxframer-motiontailwind-merge- Source
- 263 lines, 12 KB in one file
- Install
wensity add navbar-with-frosted-glass --type block- Tags
- light, dark, glass, sticky, mobile-ready
- Last updated


