Most demos need a newer browser

They use :has() and container queries. Update your browser, or on an iPhone update iOS to 16.4 or later.

CSS Frosted Navbar

A sticky nav bar with backdrop-filter: blur() that frosts scrolling content, plus a slide-in panel and a fix for dropdowns inside the frosted bar.

Level
Beginner
Published
Updated
Reading time
6 min

Try it

3 live demos

Your browser can't run this demo

It needs :has(), which this browser doesn't support yet. It works in Chrome 105+, Edge 105+, Firefox 121+ and Safari 15.4+.

Needs :has()

Home Forms Layout
Scroll
down
and
watch
it
blur

Scroll the colors under the glass

Other ways to build it

Build it

6 snippets to copy

CSS Frosted Navbar

HTML

<div class="fn-window" tabindex="0" role="region" aria-label="Scrollable sample page">
  <div class="fn-bar">
    <span class="fn-logo">Site name</span>
    <span class="fn-links">
      <a href="/">Home</a>
      <a href="/form/">Forms</a>
      <a href="/layout/">Layout</a>
    </span>
  </div>
  <div class="fn-block">Scroll</div>
  <div class="fn-block">down</div>
  <div class="fn-block">and</div>
  <div class="fn-block">watch</div>
  <div class="fn-block">it</div>
  <div class="fn-block">blur</div>
</div>

CSS

.fn-window {
  width: 100%;
  max-width: 36rem;
  height: 22rem;
  overflow-y: auto;
  border: 1px solid #2a2a2d;
  border-radius: 12px;
  background: #1c1c1e;
}

.fn-window:focus-visible {
  outline: 2px solid #f0f0f0;
  outline-offset: 3px;
}

/* the whole effect: sticky, a thin fill, and the blur behind it */
.fn-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .22);
  font-weight: 600;
  color: #fff;
  background: rgba(12, 12, 13, .52);
  -webkit-backdrop-filter: blur(1rem);
  backdrop-filter: blur(1rem);
}

.fn-logo {
  font-size: 1.05rem;
  font-weight: 800;
}

.fn-links {
  display: flex;
  gap: 1rem;
  font-size: .9rem;
}

.fn-links a {
  color: inherit;
  text-decoration: none;
}

.fn-links a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.fn-links a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* bright blocks with large words: sharp edges are what make
   the blur easy to see */
.fn-block {
  display: grid;
  place-items: center;
  min-height: 13rem;
  font-size: 3.6rem;
  font-weight: 800;
  line-height: 1;
  color: #0c0c0d;
}

/* the first block starts behind the bar with its word half
   under it, so the frost shows at load */
.fn-bar + .fn-block {
  align-items: start;
  margin-top: -3.2rem;
  padding-top: 1.5rem;
}

/* the bar is the first div, so the colors start at 2, with the
   brightest first */
.fn-block:nth-of-type(6n + 2) { background: #ffd444; }
.fn-block:nth-of-type(6n + 3) { background: #f472b6; }
.fn-block:nth-of-type(6n + 4) { background: #38bdf8; }
.fn-block:nth-of-type(6n + 5) { background: #ff6b6b; }
.fn-block:nth-of-type(6n) { background: #57d9a3; }
.fn-block:nth-of-type(6n + 1) { background: #c084fc; }

/* as tall as the window, so even the last color can reach the bar */
.fn-block:last-child {
  min-height: 100%;
}

/* no blur at all: a nearly solid fill keeps the text readable.
   Test both spellings, or a browser with only the prefixed one
   would get the solid fill as well as the blur. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .fn-bar {
    background: rgba(12, 12, 13, .94);
  }
}

A slide-in menu panel

The panel sits outside the scroll container, so it stays in place while the page scrolls behind it. A checkbox inside the bar opens it: the input is a 1 by 1 pixel box at opacity 0 but stays focusable, and the label carries the visible icon. The panel sits under the bar in the stacking order, so the Menu label stays reachable when the panel is open. Useful for phone navigation or any bar with more links than it can hold.

HTML

<div class="fn-frame">
  <div class="fn-window" tabindex="0" role="region" aria-label="Scrollable sample page with a menu">
    <div class="fn-bar">
      <span class="fn-logo">Site name</span>
      <label class="fn-menu"><input type="checkbox"><svg viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M0 96C0 78.3 14.3 64 32 64l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 288c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32L32 448c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"/></svg> Menu</label>
    </div>
    <div class="fn-block">Scroll</div>
    <div class="fn-block">down</div>
    <div class="fn-block">and</div>
    <div class="fn-block">watch</div>
    <div class="fn-block">it</div>
    <div class="fn-block">blur</div>
  </div>
  <div class="fn-panel">
    <a href="/">Home</a>
    <a href="/form/">Forms</a>
    <a href="/navigation/">Navigation</a>
    <a href="/layout/">Layout</a>
  </div>
</div>

CSS

/* adds to the main example: .fn-window, .fn-bar, .fn-logo and
   .fn-block come from there */
.fn-frame {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 36rem;
  overflow: hidden;
  border-radius: 12px;
}

.fn-frame .fn-window {
  display: block;
  max-width: none;
}

/* the frame clips the window's own ring, so the frame draws it */
.fn-frame .fn-window:focus-visible {
  outline: none;
}

.fn-frame:has(.fn-window:focus-visible) {
  outline: 2px solid #f0f0f0;
  outline-offset: 3px;
}

.fn-menu {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 1.5rem;
  font-size: .9rem;
  cursor: pointer;
}

/* the box stays focusable, it is only moved out of sight */
.fn-menu input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.fn-menu:has(:focus-visible) {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 3px;
}

.fn-menu svg {
  width: .95rem;
  height: .95rem;
}

/* the panel sits outside the scroller, so it stays put while the
   page moves behind it, and under the bar, so the Menu control
   stays reachable. visibility keeps its links out of the tab order
   while it is closed. */
.fn-panel {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 0;
  display: grid;
  align-content: start;
  gap: .2rem;
  width: 62%;
  max-width: 15rem;
  padding: 4rem .9rem .9rem;
  border-left: 1px solid rgba(255, 255, 255, .22);
  color: #fff;
  background: rgba(12, 12, 13, .52);
  -webkit-backdrop-filter: blur(1rem);
  backdrop-filter: blur(1rem);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .3s ease, visibility 0s linear .3s;
}

.fn-frame:has(.fn-menu input:checked) .fn-panel {
  transform: none;
  visibility: visible;
  transition: transform .3s ease;
}

.fn-panel a {
  padding: .55rem .6rem;
  border-radius: 6px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

.fn-panel a:hover {
  background: rgba(255, 255, 255, .22);
}

.fn-panel a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  .fn-panel,
  .fn-frame:has(.fn-menu input:checked) .fn-panel {
    transition: none;
  }
}

A dropdown inside the bar

A child element with backdrop-filter inside a parent that also has backdrop-filter can only see what is inside the parent's filter group. Its blur applies to the parent's surface rather than the page, so the stripes stay sharp under the open dropdown on the left.

HTML

<div class="fn-pair">
  <div class="fn-case">
    <span class="fn-case-name">Broken: filter on the bar</span>
    <div class="fn-window" tabindex="0" role="region" aria-label="Scrollable sample page, broken dropdown">
      <div class="fn-bar">
        <span class="fn-logo">Site name</span>
        <details class="fn-drop" open>
          <summary>Guides</summary>
          <div class="fn-sheet">
            <a href="/form/">Forms</a>
            <a href="/navigation/">Navigation</a>
            <a href="/layout/">Layout</a>
          </div>
        </details>
      </div>
      <div class="fn-block">Scroll</div>
      <div class="fn-block">down</div>
    </div>
  </div>
  <div class="fn-case fn-fixed">
    <span class="fn-case-name">Fixed: filter on bar::before</span>
    <div class="fn-window" tabindex="0" role="region" aria-label="Scrollable sample page, fixed dropdown">
      <div class="fn-bar">
        <span class="fn-logo">Site name</span>
        <details class="fn-drop" open>
          <summary>Guides</summary>
          <div class="fn-sheet">
            <a href="/form/">Forms</a>
            <a href="/navigation/">Navigation</a>
            <a href="/layout/">Layout</a>
          </div>
        </details>
      </div>
      <div class="fn-block">Scroll</div>
      <div class="fn-block">down</div>
    </div>
  </div>
</div>

CSS

/* adds to the main example: .fn-window, .fn-bar, .fn-logo and
   .fn-block come from there */
.fn-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  width: 100%;
  max-width: 44rem;
}

.fn-case {
  display: grid;
  gap: .45rem;
}

.fn-case-name {
  font-family: monospace;
  font-size: .78rem;
}

.fn-case .fn-window {
  height: 17rem;
}

/* hard stripes under the dropdown: the failure is obvious on them */
.fn-case .fn-block {
  min-height: 11rem;
  font-size: 2.4rem;
  background: repeating-linear-gradient(90deg, #fff 0 8px, #101014 8px 16px);
  color: #fff;
  text-shadow: 0 0 .6rem #000, 0 0 .2rem #000;
}

.fn-drop {
  position: relative;
  font-size: .9rem;
}

.fn-drop summary {
  cursor: pointer;
}

.fn-drop summary:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 3px;
}

.fn-sheet {
  position: absolute;
  top: calc(100% + 1rem);
  right: -.4rem;
  display: grid;
  gap: .1rem;
  width: 9.5rem;
  padding: .4rem;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px;
  background: rgba(12, 12, 13, .52);
  -webkit-backdrop-filter: blur(1rem);
  backdrop-filter: blur(1rem);
}

.fn-sheet a {
  padding: .4rem .55rem;
  border-radius: 5px;
  color: inherit;
  text-decoration: none;
}

.fn-sheet a:hover {
  background: rgba(255, 255, 255, .22);
}

.fn-sheet a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -2px;
}

/* the fix: the bar's frost moves to a pseudo-element, so the bar
   itself has no filter and the dropdown can see the page */
.fn-fixed .fn-bar {
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.fn-fixed .fn-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(12, 12, 13, .52);
  -webkit-backdrop-filter: blur(1rem);
  backdrop-filter: blur(1rem);
}

Understand it

How it works and 6 properties

A frosted nav bar needs two things: position: sticky to keep the bar in place as the page scrolls, and backdrop-filter: blur(1rem) to blur whatever passes behind it. Because the property was first shipped in WebKit with a vendor prefix, the code includes both -webkit-backdrop-filter and the unprefixed spelling so browsers that only have one spelling still get the blur.

The fill on the bar matters as much as the blur. A bar too thin lets text drop below readable contrast over bright blocks behind it. Two variants follow: a slide-in panel that uses the same frosting, and a side-by-side demo of what happens when a frosted element sits inside a frosted bar.

How it works

The scrollable window holds a sticky .fn-bar with background: var(--fn-fill) (dark theme: rgba(12, 12, 13, .52)), -webkit-backdrop-filter: blur(1rem), and backdrop-filter: blur(1rem). The first content block starts behind the bar with a negative top margin so the blur is visible at load. Six bright blocks fill the window; the last block is min-height: 100% so any of the six colors can reach the bar no matter where the scroll stops.

The @supports not condition checks both spellings: not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))). Checking only the unprefixed form would also match in a browser that supports the prefixed property, giving it the solid fallback fill on top of a blur it can perform.

The dark fill is rgba(12, 12, 13, .52) and the light fill is rgba(255, 255, 255, .42). Dark theme contrast over the six blocks goes as low as 5.18, over yellow; light theme as low as 6.61. The fallback fill, which fires when @supports not is true, uses rgba(12, 12, 13, .94) dark and rgba(255, 255, 255, .94) light; its lowest contrast figures are 18.38 dark and 15.93 light.

A backdrop-filter on a parent creates a filter group, and a child's backdrop-filter can only see inside that group, not the page behind the parent. A dropdown inside a frosted bar blurs the bar's own surface rather than the content below it, leaving the stripes sharp under the left demo window's dropdown. Moving the bar's filter and fill to a ::before pseudo-element removes the filter group from the bar itself. The ::before uses position: absolute; inset: 0; z-index: -1 to stay inside the bar's stacking context, and the bar looks the same from the front.

Two properties create a stacking context without blocking a child's blur: isolation: isolate and transform. The properties that do block it: a backdrop-filter on the parent itself, filter (including filter: brightness(1.01)), mask-image, mix-blend-mode, and will-change: opacity. opacity: .99 blocks in Chromium but not in Firefox.

The slide-in panel uses visibility: hidden on the closed state rather than display: none. transition: transform .3s ease, visibility 0s linear .3s delays the visibility change until the outward slide finishes, keeping the panel visible as it moves.

Accessibility notes

The scrollable window has role="region" and aria-label="Scrollable sample page", making it a named landmark. Tab lands on the window first, and it can be scrolled from the keyboard with PageDown or ArrowDown.

The slide-in panel's Menu label contains a visually hidden checkbox and a bars icon marked aria-hidden. Tab from the window goes to the Menu checkbox, and pressing space opens the panel. Links inside the closed panel are absent from the tab order because visibility: hidden removes them; after opening, Tab reaches them.

Bar links have a 2px focus ring on :focus-visible. Under prefers-reduced-motion: reduce, the panel opens and closes without animation.

Mistakes worth avoiding

  • Omitting the -webkit-backdrop-filter spelling. Browsers that shipped only the prefixed version will render no blur.
  • Skipping the @supports fallback. Without it, a browser with no backdrop-filter support shows the thin semi-transparent fill with no frosting behind it. The bar appears see-through and the content behind it is unblurred, which was not the intended appearance.
  • Nesting a backdrop-filter element inside a parent that also has backdrop-filter.
  • Setting will-change: opacity on the bar. This blocks a nested element's backdrop-filter in both Chromium and Firefox.
  • Using ::before { z-index: -1 } on a bar that has no stacking context. A bar with position: sticky already has one; a bar with only position: relative and no z-index does not, and ::before { z-index: -1 } will drop behind content blocks outside the bar.

Ship it

8 features in 4 browsers, 3 questions

Browser support

Feature Chrome Firefox Safari Edge
backdrop-filter76103917
position: sticky91597.191
@supports2822912
:has()10512115.4105
details1249679
transform43.53.112
transition455.112
prefers-reduced-motion746310.179

backdrop-filter is the feature that drives the blur. Can I Use shows it from Chrome 76, Firefox 103, and Edge 17. Safari's figure of 9 reflects the property's first appearance as -webkit-backdrop-filter, which is why the code includes both spellings. :has() is the most recent dependency at Chrome 105, Firefox 121, and Safari 15.4.

What you can build with it

  • Site navigation. A header that stays in view as the page scrolls, with the blur letting users see the color of the content section below the bar.
  • Application chrome. Top bars and side rails in a dashboard that remain readable over colored card grids or data tables scrolling behind them.
  • Slide-in menus. A panel that opens over scrolling content without stopping the scroll, with the frosted treatment connecting the panel visually to the page behind it.
  • Frosted dropdowns. Navigation menus that open below a frosted bar and need their own blur. Move the bar's filter to a ::before so both layers blur the page rather than each other.

Frequently asked questions

Why does backdrop-filter need a -webkit- prefix?
WebKit shipped the property as -webkit-backdrop-filter before the standard property was finalized, and some browsers only carry that spelling. The @supports condition in the code tests both spellings so those browsers do not receive the solid fallback fill even though they can perform the blur.
What happens in browsers without backdrop-filter support?
The @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) block gives the bar a nearly opaque fill: rgba(12, 12, 13, .94) in the dark theme, rgba(255, 255, 255, .94) in the light. The bar stays sticky and fully functional; only the blur is absent.
Does backdrop-filter work in Firefox?
Yes, from Firefox 103.