React navbar components

12 navbar componentsLive previewFull source in your repo

Responsive navigation bars with the mobile menu, the sticky scroll state and the keyboard handling already finished. One command copies the source into your repository.

Works with

  • React
  • Next.js
  • TypeScript
  • Tailwind CSS

Responsive navbar examples you can copy

Each navbar is a single file covering the desktop bar, the mobile drawer and the scroll transition. Preview it live, then copy the source into your project.

Animated navigation menus, docks and hamburger icons

Navigation with motion built in: an animated hamburger menu for the mobile toggle, a magnetic macOS style dock, a gooey dock, gooey menus, and the accessible Navigation Menu primitive they can sit beside.

The accessible pieces underneath: dropdown panels, command search, breadcrumbs, tabs and app sidebars, plus a dark mode toggle for the right side of the bar, animated tabs and link underlines. Use them to extend a navbar or build one from scratch.

A navbar has one job that matters: tell people where they are and where else they can go, without taking room the content needs. The usual navbar design is a logo on the left, four to six links in the middle and one call to action on the right. Most of the difficulty is not visual. It is deciding what earns a top level slot, because past six items people stop reading and start scanning, so the rest belongs in a dropdown or in the footer.

The first real decision is whether the bar sticks. A sticky navbar keeps navigation one click away on a long page, which suits documentation and marketing sites where people jump around. It also costs around sixty pixels of height permanently, which matters more on a phone than on a laptop. Navbar With Frosted Glass and Navbar With Hover Pill Links both stick, and the frosted bar adapts its blur once you scroll so the content underneath stays legible.

Floating navbars detach from the top edge and sit on the page as a rounded pill. Navbar With Floating Pill centres a dark blurred pill with a gradient call to action, and Navbar With Floating Pill Menu adds a spring loaded dropdown on a glass backing. They read lighter than a full width bar but leave the page visible behind them, which works over a solid or gently animated hero and falls apart over a busy photograph. Check the contrast against your real hero before committing.

When the product has more pages than the bar can hold, use a dropdown rather than more links. Navbar With Mega Menu Dropdown opens a floating card under the link with an icon circle beside each item, and Navbar With Centered Links pairs centred links with a single dropdown. Both keep the top bar short while still exposing a dozen destinations in one move.

Mobile is where navbars usually break, so test it before you pick. The mobile menu here opens as a full drawer rather than a cramped dropdown, traps focus while open, closes on Escape and returns focus to the trigger. Those four behaviours separate a working menu from one that strands keyboard and screen reader users, and they are tedious enough that most hand rolled navbars skip at least one. The button that opens it matters too: Animated Hamburger Menu turns its bars into a close X or a back arrow and reports the state with aria-expanded, so the icon always matches what the drawer is doing.

If the site has more than a couple of dozen destinations, add search instead of more links. Command gives you a palette on the standard keyboard shortcut, which regular visitors reach for before they read the bar at all. Pair it with a compact navbar rather than trying to express the whole information architecture across the top of the screen.

Mark the current page. A link that looks the same on every route leaves people guessing where they are, especially after arriving from search. Highlight the active item with weight or a pill rather than colour alone, so the state survives for colour blind visitors and in both light and dark mode.

Frequently asked questions

A logo that links home, the four to six destinations most visitors need, and one primary call to action such as Sign up or Start free. Optional extras are a search or command trigger and a sign in link. Everything else belongs in a dropdown, a sidebar or the footer, because each extra link makes the important ones harder to find.

Run the Wensity CLI with the block slug, for example npx wensity@latest add navbar-with-frosted-glass --type block. The CLI copies the navbar into your codebase along with its mobile drawer, installs what it needs, and matches your Tailwind theme. You can also copy the source directly from the Code tab on any navbar page.

Use the CSS sticky position rather than JavaScript scroll listeners: a wrapper with position sticky and top zero costs nothing at runtime and never lags behind the scroll. The navbars here that change appearance on scroll use a single IntersectionObserver on a sentinel element above them, which fires twice per page rather than on every scroll frame.

Yes. The dropdown panels are built on Radix and Base UI primitives, so arrow key navigation, Escape to close, focus return to the trigger and the correct ARIA roles all come with them. The mobile drawers trap focus while open and restore it on close. This is the part most custom navbars get wrong, so it is worth keeping rather than rebuilding.

Render the toggle as a real button, keep the open state in React and pass it to both the icon and the drawer, then set aria-expanded and aria-controls on the button. Animated Hamburger Menu does the icon part with CSS transitions alone, in eight variants that morph the bars into a close X or a back arrow, and it takes open and onOpenChange so a tap on a menu link can close it. Install it with npx wensity@latest add animated-hamburger-menu, or with npx shadcn@latest add @wensity/animated-hamburger-menu.

Place it at the right end of the bar, next to the call to action, and make it follow the system setting until the visitor picks a theme. Dark Mode Toggle covers this in five shapes, from a day and night switch to a Light, System and Dark menu, saves the choice in localStorage and can reveal the new theme in a circle from the button. Put the small inline script from its usage example in the document head so a dark visitor never sees a light flash on load. It is part of Wensity Pro and installs with npx wensity@latest add dark-mode-toggle.

Not reliably. A floating bar like Navbar With Floating Pill Menu shows the page behind it, so contrast between the link text and whatever scrolls underneath changes as the user moves. Over a solid or lightly animated background it is fine. Over a photograph or a busy shader it is not, and a sticky bar with a solid or blurred backdrop is the safer pick.

Read the current path and compare it against each link. In the Next.js App Router that is the usePathname hook in a client component. The navbars here accept an active prop on each item so you can drive it from whatever router you use, which keeps the component itself framework agnostic.

Where to go next