Sticky Scroll Shadow
A navbar pinned to the top of the viewport with `sticky top-0` that stays borderless and flat at the top of the page, then picks up a visible shadow and border the moment the page scrolls past a small threshold, a common way to give a sticky header some depth once content is passing underneath it.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/sticky-scroll-shadow.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/navbar/navbar14.tsx instead.
Usage
The file also exports navbar14Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Navbar14, navbar14Demo } from "@/components/blocks/navbar/navbar14"; export default function Page() { return <Navbar14 {...navbar14Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| wordmark | string | "Solace" | Logo text rendered as a bold wordmark. |
| links | { label: string; href: string }[] | none | Primary nav links, shown on medium screens and up. |
| cta | { label: string; href: string } | none | The single call-to-action button on the right. |
| className | string | none | Extra classes for the outer header element. |
Behavior notes
- Real client-side behavior: a useEffect attaches a genuine `scroll` event listener and flips a useState boolean once the page has scrolled more than 10px, which swaps in a shadow and a solid border class.
- The scroll listener is attached to `headerRef.current.ownerDocument.defaultView`, not the bare `window` global, this repo's block detail pages render the live preview inside a portaled iframe, and listening on the bare `window` would attach to the wrong (parent) window and never fire for scrolling inside the iframe.
- The listener is removed in the effect's cleanup function on unmount, and it also runs once immediately on mount to set the correct initial state.
- The header itself uses `sticky top-0 z-10` positioning so it stays pinned while the rest of the page scrolls underneath it.
More Navbar Blocks
View all →Simple Logo Links CTA
Wordmark on the left, a row of nav links, and a single CTA button on the right.
Centered Logo Split Links
Logo centered in the header with nav links evenly split to its left and right.
Mega Menu Dropdown
A trigger that opens a wide, multi-column mega menu panel below the header.
Navbar With Search
Logo, a few nav links, and a labeled search input with an inline icon.
Two Tier Utility Nav
A thin utility link row above the main navigation row.
Minimal Logo CTA Only
The simplest possible header: just a logo and a single CTA button, no nav links.