N
NJHTools

Tailwind CSS Navbar Examples

Responsive navigation bars for landing pages and apps — a simple link bar, a navbar with call-to-action buttons and a hamburger mobile menu built on native <details>.

3 components · live preview · copy as HTML or JSX · free for commercial use

3 navbars to copy

Building a responsive navbar

A navbar needs to do three things at every screen size: show the brand, give access to every top-level link and keep the main call to action in reach. The simplest responsive pattern is to let the links wrap onto a second row on small screens (flex-wrap, or order-last w-full as in the CTA navbar), which needs no JavaScript and hides nothing. Once you have more than four or five links, collapse them into a menu below the md breakpoint instead.

The mobile menu example uses the native <details> and <summary> elements: the browser handles the open and closed state and the keyboard, and Tailwind's named group-open/menu variant swaps the hamburger icon for a close icon. The dropdown panel is positioned absolute inset-x-0 top-full against the relative header, so it overlays the page instead of pushing content down.

Accessibility checklist

Wrap the links in a <nav> with an aria-label such as "Main" so screen-reader users can jump straight to it, and give icon-only toggles an accessible name (aria-label="Menu"). Mark the current page with aria-current="page" rather than color alone. If the navbar is sticky (sticky top-0 z-50), add scroll-margin-top to in-page anchors so headings are not hidden underneath it.

← Back to the full UI Component Library

Frequently Asked Questions

How do I make a Tailwind navbar responsive?↓

Show the full link list from the md breakpoint up (hidden md:flex) and a menu button below it (md:hidden). For short link lists, flex-wrap alone is often enough: the links drop to a second row on phones.

Can I build a mobile hamburger menu without JavaScript?↓

Yes. Put the menu inside a <details> element with the hamburger icon in its <summary>. The browser toggles it on click and with the keyboard, and the group-open: variant styles the open state.

How do I make a navbar sticky in Tailwind?↓

Add sticky top-0 z-50 to the <header>, plus a background color (and optionally backdrop-blur) so page content does not show through while scrolling.

Last updated: