React Floating Pill Navbar with Dropdown Menus

Pro

A true pill: fully rounded, sized to its contents and floating 16px below the top of the page. Hover Features or Solutions and a rounded panel of described links drops out of it. The pill itself starts lightly frosted and turns more solid, with a shadow, once you scroll.

Dropdowns from inside a floating pill

Navbar with Floating Pill Menu is a React and Tailwind CSS floating pill navbar: a rounded-full navigation bar centred near the top of the viewport that also opens dropdown menus, so a site with grouped pages can still use a detached header. It runs in Next.js or any React app.

Floating headers usually drop menus because there is no room in a pill for a wide panel. This block keeps the dropdown compact at 320px, anchors it inside the pill's link rail, and lets one shell switch contents with a direction aware spring, so moving from Features to Solutions slides the panel instead of reopening it.

The glass reacts to scroll. At the top of the page the pill is white at 75 percent with a medium blur; past 20px it firms up to 92 percent, adds a stronger blur and a soft drop shadow, which keeps it readable over busy sections further down.

What sits inside the pill

Rounded full shell

A motion nav with rounded-full corners and padding on all sides, so it wraps the brand, the rail and the button tightly. It drops in 12px on mount.

Two glass states

Light frost below 20px of scroll, denser frost with a shadow above it. The dark version moves from 75 to 92 percent deep navy.

Compact dropdown

A 320px rounded card under the rail with icon tiles, labels and descriptions, springing in 40ms apart and nudging a chevron on hover.

Variable accent

accentColor feeds three CSS variables: the button fill, a hover tint mixed 82 percent with white, and a 3px ring mixed at 30 percent, all through color-mix.

Single action

There is one call to action and no Sign in link, which keeps the pill short enough to float.

Rounded drawer

On phones a rounded glass card opens under the pill with the top level links and the button.

Who this pill is for

Use it when

  • You like the floating look but have two groups of pages that need a short menu each.
  • A single call to action is enough, with sign in reachable elsewhere.
  • Your hero is dark or colourful and the pill should sit over it like an object.
  • You want to change the brand colour in one prop, hover and ring included.

Skip it when

  • Phone visitors need the sub pages. The drawer lists only the top level links, so dropdown items are unreachable on small screens until you add them.
  • Keyboard access to the dropdowns is required now, since they open on pointer hover only.
  • You need more than five top level entries, which stretches the pill beyond comfortable width.
  • Your audience uses older browsers without color-mix support, where the hover and ring tints fall away.

Configure the menus and the accent

Links follow the same shape as the other dropdown navbars: a label and href, plus an items array for anything that should open a panel. Icons come from a map keyed by label inside the file, with a two letter tile for anything not in it. accentColor sets the button and its tints; ctaClassName takes extra classes when you want a gradient or a different text colour.

Two edits in the file are worth making before launch. Delete the demo headline under the header, Built for speed, and extend the mobile drawer so groups with items render their children, otherwise phone users never see Workflows, Startups or whatever you put in the menus.

npx wensity@latest add navbar-with-floating-pill-menu --type block
page.tsx
import { NovaNavbar } from "@/components/wensity/blocks/navbar-with-floating-pill-menu";
export function Header() {
return (
<NovaNavbar
brandName="Tidepool"
links={[
{
label: "Platform",
href: "/platform",
items: [
{ label: "Pipelines", description: "Schedule and retry jobs", href: "/pipelines" },
{ label: "Alerts", description: "Page the right person", href: "/alerts" },
],
},
{ label: "Customers", href: "/customers" },
{ label: "Pricing", href: "/pricing" },
]}
accentColor="#5eead4"
cta={{ label: "Book a demo", href: "/demo" }}
/>
);
}

Props

PropTypeDefaultDescription
linksNovaNavbarLink[]Features, Solutions, Pricing, Docsitems on an entry gives it a dropdown inside the pill. Keep labels short so the pill stays compact.
accentColorstring"#a78bfa"Button fill plus derived hover and ring colours. The button text is near black, so light accents work best here.
ctaClassNamestring-Extra classes on both copies of the button, for a gradient fill or a different text colour.
cta{ label: string; href: string }Get startedThe only action in the pill.
brandHrefstring"/"Destination of the logo link.
logoReactNode-Replaces the violet orb sample mark beside brandName.

Gaps to close before launch

Phone menu skips sub pages

The drawer maps every link to its own href and ignores items. Render each group's items under its label, or make the group label link to an overview page that lists them.

Pointer only dropdowns

Triggers are buttons with onMouseEnter and no click, focus or Escape handling, and entries without items do not navigate on desktop. Add those handlers and turn plain entries into anchors.

Motion settings

The drop in, the panel spring and the row stagger do not read prefers-reduced-motion. MotionConfig with reducedMotion set to user handles all three.

Scroll threshold

One passive listener compares scrollY with 20. There is no loop or observer running otherwise.

Block details

Navbar With Floating Pill Menu
Category
Navbars
Renders
JavaScript animation. Paints first, then animates
Theme
Follows the site theme in light and dark
Dependencies
clsxframer-motiontailwind-merge
Source
387 lines, 19 KB in one file
Install
wensity add navbar-with-floating-pill-menu --type block
Tags
light, dark, pill, floating, spring, premium
Last updated

Pair the pill with a dark hero or a plain one