Black Friday is here 🔥 Get Wensity Pro for 20% less with

React Centered Navbar with Wide Dropdown Panels and Featured Cards

Pro

A three column header for a product with a lot to explain: brand on the left, the link rail dead centre, sign in and a blue call to action on the right. Hovering a link opens a white panel that grows to fit a short list, a list with one featured card, or a list with two.

Why the links sit in the middle

Navbar with Centered Links is a React and Tailwind CSS navigation bar that places the logo, the menu and the buttons in three equal columns, so the links stay in the optical centre of the page however long the brand name or the button labels are. It ships as one client component for Next.js or any React app, with a mobile drawer included.

Most centred navbars are a flex row with auto margins, and they drift off centre the moment the left and right clusters differ in width. This one uses a grid of 1fr, auto and 1fr. The middle track is only as wide as the links, and the two outer tracks always split what is left, so the rail lands in the middle of the viewport rather than the middle of the leftover space.

The dropdowns are where the block earns its keep. Each top level link can carry a list of items with short descriptions and up to two featured cards with their own visual. The panel measures its content and springs between 320, 520 and 660 pixels wide, and when you slide from one menu to the next the content moves left or right to match the direction your pointer travelled.

Inside the centred header

Three column grid

Brand, rail and actions sit in grid-cols-[1fr_auto_1fr] at 60px tall. The left and right tracks are equal, which is the whole trick behind a rail that never slides off centre.

Scroll state

The bar starts transparent. Once the page has scrolled past 8px it gains a white 90 percent fill, a backdrop blur and a hairline bottom border, with a near black version in dark mode.

Measured dropdown shell

A ResizeObserver reads the open menu's height, and Framer Motion springs the shell's width and height to match. The top left corner stays pinned, so the panel grows down and to the right instead of jumping.

Item rows

Every item is an icon tile, a label and a one line description. The tile inverts to black on hover. Labels without a matching icon fall back to their first two letters, so custom items still look finished.

Featured cards

A link with featured entries gets a column of one card or a row of two, each with an optional 80px visual, a title, a three line description and a Learn more cue.

Mobile drawer

Below 768px the rail becomes a hamburger. The drawer expands each group as an accordion, one at a time, and ends with both buttons stacked full width.

Good fit, poor fit

Use it when

  • Your product has three or four areas that each need a sentence of explanation before someone clicks.
  • You want to promote a case study or a quick start guide from inside the menu instead of on a separate page.
  • Your logo and your button group are different widths and you are tired of the links looking off centre.
  • The site is light by default and you want the header to blend into the hero until the visitor scrolls.

Skip it when

  • Keyboard and screen reader access to the dropdowns is a requirement today. The panels open on pointer hover only, so plan the fix described below before launch.
  • You have five links or fewer and none of them need sub pages. A plain bar is lighter and easier to scan.
  • Your brand colour is not blue and you would rather not edit the button classes in the file.
  • The header must sit inside an existing layout, since the block also renders a demo headline underneath that you have to delete.

Install it and rebuild the menus with your own pages

The links prop describes the whole menu. Give a link an items array to turn it into a dropdown, and add one or two featured objects to widen the panel and show cards beside the list. A featured visual can be any React node, so a small screenshot, an illustration or a code snippet all work.

Two edits happen in the file itself. First, delete the demo section under the header, the one with the Built to ship headline, since it is not controlled by a prop. Second, change the bg-[#3b82f6] classes on both primary buttons if your brand is not blue. The logo link always points at the root path, so edit that anchor if your home lives elsewhere.

npx wensity@latest add navbar-with-centered-links --type block
page.tsx
import { TersynNavbar } from "@/components/wensity/blocks/navbar-with-centered-links";
export function SiteHeader() {
return (
<TersynNavbar
brandName="Fieldnote"
links={[
{
label: "Product",
href: "/product",
items: [
{ label: "Editor", description: "Write and review in one place", href: "/editor" },
{ label: "Sync", description: "Offline first, conflict free", href: "/sync" },
],
},
{
label: "Resources",
href: "/resources",
items: [{ label: "Guides", description: "Short how to articles", href: "/guides" }],
featured: [
{ title: "Quick start", description: "Your first project in ten minutes.", href: "/start" },
],
},
{ label: "Pricing", href: "/pricing" },
]}
primaryCta={{ label: "Try it free", href: "/signup" }}
secondaryCta={{ label: "Log in", href: "/login" }}
/>
);
}

Props

PropTypeDefaultDescription
linksTersynNavbarLink[]Product, Solutions, Resources, PricingTop level entries. items turns one into a dropdown, featured adds cards and widens the panel to 520 or 660px.
logoReactNode-Your mark, rendered beside brandName. Without it the block draws its own geometric sample mark.
brandNamestring"Tersyn"The wordmark text and the accessible name of the home link.
primaryCta{ label: string; href: string }Get started freeThe filled blue button on the right, repeated at the foot of the mobile drawer.
secondaryCta{ label: string; href: string }Sign inA quiet text link before the button, hidden on the narrowest screens and shown again in the drawer.
headingAs"h1" | "h2" | "h3""h1"Only affects the demo headline under the bar. Once you delete that section the prop has nothing to control.

Accessibility gaps and runtime cost

Dropdowns are pointer only

Desktop rail entries are buttons with an onMouseEnter handler and nothing else: no click, no focus handler, no aria-expanded and no Escape key. Add onClick and onFocus that call openMenu, set aria-expanded from activeMenu, and close on Escape before shipping to keyboard users.

Plain links do not navigate on desktop

An entry without items, such as Pricing, also renders as a button, so its href is ignored on wide screens and only works in the mobile drawer. Render those entries as anchors in the rail.

Motion is always on

The panel spring, the sideways slide and the staggered rows run regardless of prefers-reduced-motion. Wrapping the header in MotionConfig with reducedMotion set to user turns the transforms off.

One scroll listener

A passive scroll handler flips a single boolean at 8px, and a ResizeObserver runs only while a panel is open. There is no animation loop when nothing is moving.

Sticky, not fixed

The header is position sticky inside its own wrapper, so it only sticks while that wrapper is in view. Mount it at the top of your layout, outside any element with overflow hidden.

Block details

Navbar With Centered Links
Category
Navbars
Renders
JavaScript animation. Paints first, then animates
Theme
Follows the site theme in light and dark
Dependencies
clsxframer-motiontailwind-merge
Source
636 lines, 35 KB in one file
Install
wensity add navbar-with-centered-links --type block
Tags
light, dark, centered, custom-logo, spring, premium
Last updated

Headers and heroes that suit a centred rail