Skip to content

Navbar with Centered Logo

Dark Tailwind CSS navbar with links split around a centered logo, animated underlines and an accessible slide-down mobile menu.

Also known as: centered logo navbar, split navigation bar, dark navbar with hamburger menu, logo in the middle navigation

Navbar with Centered Logo live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A dark, boutique-style navigation bar built with Tailwind CSS where the links are split into two groups on either side of a centered logo. It collapses into a hamburger menu with a slide-down panel on phones, which makes it a good fit for fashion stores, studios, restaurants and brand sites.

How it works

The root is header.tnc-navbar. The nav uses a three-column grid, grid-cols-[1fr_auto_1fr], so the logo stays exactly centered however wide the link groups are. The left column holds the .tnc-toggle button (below md only) and the first link list, the center holds the SVG mark and "Lumen" wordmark, and the right holds the second link list and a bag link with a count badge.

Desktop links get an animated underline from after: utilities: a 1px amber line that grows from after:scale-x-0 to after:scale-x-100 on hover. The aria-[current=page]: variant keeps it visible on the active link.

On small screens the #tnc-menu panel (.tnc-panel) lists every link plus a call-to-action. On DOMContentLoaded the script initializes each .tnc-navbar. Clicking .tnc-toggle flips aria-expanded, toggles the panel's hidden attribute and swaps the icons marked data-tnc-icon="open" and data-tnc-icon="close". The panel also closes on a link click, an outside click, Escape, or when the viewport crosses 48rem. style.css adds a short tnc-drop entrance animation.

Customization

  • bg-zinc-950 on .tnc-navbar and bg-zinc-950/95 on .tnc-panel: switch to bg-white and bg-white/95 (with dark text classes) for a light header.
  • after:bg-amber-400, text-amber-400 on the logo and bg-amber-400 on the badge and button: replace with another color such as rose-400 to change the accent everywhere.
  • The SVG inside the center link and the "Lumen" span: drop in your own logo; tracking-[0.25em] and font-serif give the wordmark its spaced, editorial look.
  • aria-current="page": move it to the link of the current page in both the desktop lists and the mobile panel to move the underline and amber highlight.
  • md:hidden / md:flex and (min-width: 48rem) in script.js: change both to lg and 64rem to keep the hamburger menu on tablets.
  • h-16 md:h-20 on the nav: make the bar taller or shorter.
  • animation: tnc-drop 0.22s in style.css: lengthen or remove the panel entrance.

Use cases

  • Fashion stores: links sit on either side of the logo, with a bag link and item count badge
  • Studios and agencies: a dark boutique-style header keeps the brand mark centered
  • Restaurants: a slide-down mobile panel lists every link plus a call-to-action
  • Brand websites: animated underlines mark hover and the active page link

Accessibility

The nav has aria-label="Main". The toggle is a real button with a visually hidden "Menu" label, aria-controls="tnc-menu" and an aria-expanded state kept in sync by the script; both icons are aria-hidden. Escape closes the panel and returns focus to the toggle, and the hidden panel is removed from the tab order by the hidden attribute. The bag link announces "Shopping bag, 2 items" while the visual badge is hidden from assistive technology. Every interactive element shows an amber focus-visible:outline-2 ring, touch targets are at least 44px, and light zinc text on near-black meets WCAG AA contrast. Transitions and the panel animation are disabled with motion-reduce: utilities and a prefers-reduced-motion media query.

Usage notes

To use several navbars on one page, give each panel a unique id and update aria-controls to match; the script scopes everything to each .tnc-navbar.

Navbar with Centered Logo at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile, dark design
Category
Navbars
License
Free for personal and commercial use

Questions about this template

Can I use the Navbar with Centered Logo code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Navbar with Centered Logo – free Tailwind CSS navbar template
Navbar with Centered Logo · free Tailwind CSS navbar template

More Navbars

Navbar with Sliding Active Indicator – free Pure CSS navbar template

Navbar with Sliding Active Indicator

Dark responsive navbar with a glowing underline that slides between links on hover, focus and click, built with CSS custom properties and vanilla JS.

Navbar with Offcanvas Drawer on Mobile – free Bootstrap 6 navbar template

Navbar with Offcanvas Drawer on Mobile

Responsive Bootstrap 6 navbar that shows inline links on desktop and moves them into a slide-in Drawer with icons, studio hours and social links on small screens.

Navbar with Overflow Menu (NavOverflow) – free Bootstrap 6 navbar template

Navbar with Overflow Menu (NavOverflow)

Bootstrap 6 news navbar built on the new NavOverflow component: links that do not fit move into a More menu automatically as the width shrinks.