Skip to content

Header

Header Centered

Sticky header with the brand on the left, navigation centered and a call to action on the right. It clears and fades on scroll down; link labels roll on hover.

Layout and motion from the Nitip template — see it in context

Installation

$ npx shadcn@latest add https://framebrick.co/r/blocks/header-centered.json

Usage

import { HeaderCentered } from "@/components/header-centered";

<HeaderCentered
  brand={{ name: "Northstar", href: "/" }}
  links={[
    { label: "Home", href: "/" },
    { label: "Services", href: "/services" },
    { label: "Projects", href: "/projects" },
  ]}
  cta={{ label: "Contact us", href: "/contact" }}
/>

Props

PropTypeDefaultDescription
brand{ name, href, logo? }NorthstarShown on the left; logo (any node) replaces the name.
links{ label, href }[]5 linksNavigation, centered from 768px, in the menu below.
cta{ label, href }Contact usButton at the right from 1024px, in the menu below.
currentstringusePathname()Current path. A link is current on its page and on pages below it (/projects/x under /projects).
classNamestring—Classes for the <header>.
  • Sticky, so it needs no spacer; put it first on the page, outside <main>.
  • From 1024px, scrolling down more than 4px (after the first 20px) clears the background and fades the brand and the button out in 400ms; scrolling up brings them back.
  • Hover rolls a link's label up while a copy rolls in from below (spring bounce 0.2, 0.4s, 24px). The current link is filled and doesn't roll.
  • Below 768px the menu button opens the links and the button with a height reveal; choosing a link or pressing Escape closes it.
  • Reduced motion: the roll and the reveal are skipped by MotionConfig; the fades are CSS transitions turned off with motion-reduce.

AI prompt

Paste into v0, Lovable, Bolt or Claude to rebuild this block in your own project.

Create a React + Tailwind CSS + Motion (motion/react) block called HeaderCentered using Next.js Link and usePathname.
- A sticky <header> (top-0, z-50, bg-background) with a container: mx-auto max-w-(--container) px-(--gutter), h-16 (md:h-20).
- Brand text on the left (font-heading text-lg font-semibold tracking-tight). Navigation absolutely centered from 768px in a
  box with border border-border bg-background p-1 rounded-lg, links rounded-md px-3 py-1.5 text-sm font-medium.
  The current link (its path or below it) is bg-primary text-primary-foreground with aria-current="page".
- A shadcn-style button with an arrow on the right from 1024px (the arrow turns 45° on hover).
- Link hover: bg-accent fades in over 400ms; the label sits in a 20px-tall clipped box and rolls up 24px while an identical
  copy (24px below it, aria-hidden) rolls in — spring bounce 0.2, duration 0.4s. The current link has no hover.
- Scroll (from 1024px): track scrollY; below 20px reset; scrolling down more than 4px sets data-scrolled=true, up more than 4px
  sets false. Scrolled: header background transparent, brand and button opacity 0 and pointer-events none, 400ms ease-out.
- Below 768px a "Menu / Close" button with three lines that cross into an X (aria-expanded, aria-controls) opens a panel
  under the bar: stacked links and the button. Animate height 0 → auto with a spring (bounce 0, 0.4s), opacity in 0.25s after
  0.1s, out in 0.15s. Close on link click and on Escape.
- Use only shadcn CSS variables and the block tokens (--container, --gutter, font-heading).

Be the first to know

Get new templates and components first

One short email when we release a template or a free component. No spam — unsubscribe anytime.

We use your email only for Framebrick updates. Privacy policy