Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Sticky Blur Navbar Block for React

A navbar stuck to the top of a scrolling page preview: clear at rest, frosted with a hairline once the page moves under it, with a sheet menu on phones.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A sticky navbar for React with Base UI, for a reading app called Frostline. The block is the bar and a 160-pixel page preview under it: a window that scrolls, a drawn article inside, and the bar stuck to its top. At rest the bar is clear and draws no line; as soon as the page has moved under it the bar frosts (bg-background/70 backdrop-blur-md) and gains a hairline on its bottom edge, so the lines of the article blur as they pass beneath. The wordmark leads, Library, Collections and Highlights follow with the current page marked by weight and a dot, and a Read free Shine Button closes the row; below the md breakpoint a menu button opens a sheet from the top with the same links. It's built from Sheet, Guides, Shine Button and Button, with your theme's tokens for every colour. For reading, news and documentation sites whose header stays in view while the page scrolls.

FAQ

How do I use it on a real page?

The preview window only stands in for a page. On your page, drop the section and the drawn article, keep the header, and add sticky top-0 z-40 to it (the classes that already sit on it). Then flip data-scrolled from the window's scroll: window.addEventListener("scroll", () => setScrolled(window.scrollY > 0), { passive: true }). The frosted look, the hairline and the transition are all keyed to that one attribute, so nothing else changes. The bar stays one bar high, and its top rule and rails line up with every block under it.

What does the frosted state change, and does it stay readable?

Three things: the background becomes the page colour at 70% opacity, the backdrop blurs, and an inset hairline (the theme's border colour) appears on the bar's bottom edge. The links keep the theme's own text colours on that surface, and the page lines passing under it are low-contrast greys, so the links stay legible in light and dark. The current link and the Shine Button are unchanged.

How does it work with a keyboard and a screen reader?

The preview is a named region, "Page preview", that takes focus, so the arrow keys, Page Down and Space scroll it and the bar frosts as they do; its drawn article is hidden from assistive technology. The links sit in a nav named Main after the wordmark (a link home), the current page is aria-current="page", and Tab walks the wordmark, the links, Read free and the menu button. Read free renders the link it's given with render, with nativeButton={false}.

How does it work on a phone?

Below the md breakpoint the links fold: the wordmark, Read free and a menu button stay on the bar, and nothing wraps at 320 pixels. The menu button opens a sheet from the top whose header lines up with the bar, then the same links with the current page tinted. Focus moves into the sheet and stays there; Escape, the close button or choosing a link closes it, and focus goes back to the menu button. The preview and the bar keep working behind it.

What moves, and what happens with reduced motion?

When the page starts to move the bar's background, hairline and blur ease in over a fraction of a second, and a band of light sweeps across Read free once on hover and keyboard focus. With reduced motion the frost appears at once, the sheet appears without sliding and the light fades in where it stands.

  • Pro

    Transparent Hero Navbar

    Surface and theme

    A transparent navbar laid over a hero drawing, with a scrim behind it that keeps the links readable in every theme, and a full-screen sheet on phones.

  • Pro

    Glassmorphism Navbar

    Surface and theme

    A frosted rectangular navbar panel inset in the page column, lying over a band of slowly drifting dots and soft mesh so the blur is visible, with a drawer menu on phones.

  • Pro

    Floating Pill Navbar

    Surface and theme

    A detached opaque pill navbar that hugs its content and floats centred in the page column, with the call to action inside it and a drawer menu on phones.

  • Pro

    A one-bar marketing navbar for a product roadmap tool: a wordmark, a Product menu of four areas with icons and one-line descriptions, plain links with the current page marked, Sign in and a Shine Button, and a sheet with the same links on phones.

  • Pro

    Minimal Navbar

    Link highlights

    The least navbar there is: a slim 48 px bar with a wordmark, three plain links and one Shine Button for a journaling app, with no motion, the current page marked by weight and a dot, and a bottom drawer on phones.

  • Pro

    A slim announcement strip for a writing app's release: one centred line with the version, the news and an underlined link, and a ghost button that folds the strip away.