Transparent To Solid Scroll
A navbar meant to sit on top of a hero image or section: it starts fully transparent so the content behind it shows through, then switches to a solid background with a bottom border once the page scrolls past a small threshold, a common pattern for marketing pages with a full-bleed hero.
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/transparent-to-solid-scroll.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/navbar/navbar15.tsx instead.
Usage
The file also exports navbar15Demo, 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 { Navbar15, navbar15Demo } from "@/components/blocks/navbar/navbar15"; export default function Page() { return <Navbar15 {...navbar15Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| wordmark | string | "Aperture" | 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. |
| fillerHeading | string | none | Heading shown in the decorative filler section rendered below the header. |
| fillerDescription | string | none | Supporting text shown under the filler heading. |
| className | string | none | Extra classes for the outer wrapper 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 `bg-transparent` for `bg-background border-b border-border`.
- 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.
- This block deliberately renders extra decorative filler content (a tall gradient section with a heading and description) below the header. That filler is not part of a typical reusable navbar, it exists purely so the live preview has something tall to scroll over, which is what actually demonstrates the transparent-to-solid transition; a real page would place its own hero content there instead.
- The header uses `fixed inset-x-0 top-0` positioning so it overlays the top of the filler section while transparent, then stays pinned and solid once scrolled.
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.