Staaarter

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.

By Staaarter Team
Navbar
Docs
Live preview

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.json

Prefer 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

PropTypeDefaultDescription
wordmarkstring"Aperture"Logo text rendered as a bold wordmark.
links{ label: string; href: string }[]nonePrimary nav links, shown on medium screens and up.
cta{ label: string; href: string }noneThe single call-to-action button on the right.
fillerHeadingstringnoneHeading shown in the decorative filler section rendered below the header.
fillerDescriptionstringnoneSupporting text shown under the filler heading.
classNamestringnoneExtra 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.