React Floating Navbar with a Centred Glass Pill Bar
ProInstead of a full width strip, the navigation floats as a rounded bar about 670px wide, centred, 16px below the top of the window. It is white glass over your content, with a highlight that slides between links and one accent coloured button.
A header that floats instead of spanning
Navbar with Floating Pill is a React and Tailwind CSS floating navbar: a detached, rounded navigation bar that stays centred near the top of the viewport as the page scrolls, instead of stretching edge to edge. It suits Next.js landing pages and portfolios and runs in any React app.
A floating bar leaves the hero visible on both sides of it, which matters when the hero is the product: a full bleed screenshot, a video or an animated background. The bar reads as an object placed on the page rather than a frame around it, so the first screen keeps its full width.
It arrives with a short drop in, sliding 12px down while it fades in over half a second, and then stays still. The sliding highlight between links reuses Framer Motion's shared layout animation, and the accent button takes any colour through one prop.
Parts of the floating bar
The bar
max-w-2xl, a 16px corner radius, white at 90 percent with backdrop-blur-xl and a faint border, or deep navy glass in dark mode. It is sticky at top-4, so it keeps a gap above it at all times.
Text logo
The logo prop is a node and defaults to the word Studio in bold. Pass an image, an SVG or a short brand name.
Hover highlight
A rounded tint follows the pointer between links with layoutId pill-nav-hover, using the same spring values as the minimal navbar.
Accent button
One solid button painted with accentColor, cyan by default, with an inset highlight and a slight brightness lift on hover.
Phone dropdown
Below 768px the links move into a rounded glass card that drops under the bar, with the accent button at the bottom.
When a floating bar is the right call
Use it when
- Your hero is visual and you want it to run full width behind and beside the navigation.
- Portfolios, launch pages and small product sites with four or five links.
- You want a modern detached header without dropdown logic to maintain.
- Your brand colour is strong and dark enough to carry white button text.
Skip it when
- You need submenus. The floating pill menu block adds dropdowns to the same idea.
- Your accent is a pale colour such as the default cyan, where white text on the button falls below comfortable contrast. Darken it or change the text colour.
- You want the bar to change on scroll. This one looks the same at the top and halfway down.
- Signing in is a key phone action, since the dropdown omits the Sign in link.
Install it, set the colour, trim the demo
Pass your links, both actions and an accentColor. The block also renders a short demo headline and paragraph under the bar, and unlike most navbars here those two are props: headline and subtext. That makes it handy for a one screen holding page, but on a real site you will want to delete the demo section from the file and render your own hero below.
The default subtext describes the component itself, so never ship it as is. If you keep the demo area, set headingAs to h2 whenever another h1 exists on the page.
npx wensity@latest add navbar-with-floating-pill --type block
import { FloatingPillNavbar } from "@/components/wensity/blocks/navbar-with-floating-pill";export default function ComingSoon() {return (<FloatingPillNavbarlogo={<span className="font-semibold">Orbitly</span>}brandHref="/"links={[{ label: "Work", href: "/work" },{ label: "About", href: "/about" },{ label: "Journal", href: "/journal" },]}accentColor="#0e7490"cta={{ label: "Join the waitlist", href: "/waitlist" }}headline="Launching this spring."subtext="Orbitly maps every client project on one shared timeline."/>);}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
logo | ReactNode | "Studio" | Whatever sits at the left of the bar. A short word or a small mark keeps the pill compact. |
links | { label: string; href: string }[] | Features, Pricing, Changelog, Docs | Four or five entries fit comfortably inside the 672px bar. |
accentColor | string | "#22d3ee" | Fills the button. Choose a shade dark enough for white text. |
cta | { label: string; href: string } | Get started | The accent button, repeated in the phone dropdown. |
secondaryCta | { label: string; href: string } | Sign in | Text link shown from 768px up. |
headline | ReactNode | - | Demo heading under the bar. Useful for a teaser page, otherwise delete the section. |
subtext | string | - | The line under the demo heading. Its default text describes the block, so replace it. |
Contrast, motion and small gaps
Button contrast
White text on #22d3ee measures well under the 4.5 to 1 ratio WCAG asks for normal text. Pick a darker accent such as #0e7490, or render dark text on light accents.
Entrance and hover motion
The drop in and the hover spring run for everyone. Wrap the bar in MotionConfig with reducedMotion set to user to respect the system setting.
Unlabelled brand link
The logo link has no aria-label. If you pass an image or icon, give it alt text or add an aria-label so the home link has a name.
Dropdown placement
The phone menu is absolutely positioned under the bar's starting place and does not travel with it while sticky. Close it on navigation, or make it sticky with the bar if your pages are long.
Cheap to run
No scroll listener, no timers and about 170 lines. The blur is the only ongoing cost, and it only touches the small area under the bar.
Block details
- Category
- Navbars
- Renders
- JavaScript animation. Paints first, then animates
- Theme
- Follows the site theme in light and dark
- Dependencies
clsxframer-motiontailwind-merge- Source
- 167 lines, 7 KB in one file
- Install
wensity add navbar-with-floating-pill --type block- Tags
- light, dark, floating, pill, glass
- Last updated


