Centered navigation bar in WordPress
Logo on the left, links in the middle, call to action on the right, collapsible menu on mobile.
Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.
This component also comes in
The code in WordPress
<?php
/**
* Plugin Name: Forge, Barre de navigation centrée
* Description: Logo à gauche, liens au centre, appel à l'action à droite, menu repliable sur mobile. Ajoute la composition « Barre de navigation centrée » à l'éditeur de blocs.
* Version: 1.0.0
* Requires at least: 6.6
* Requires PHP: 8.1
* Author: Forge
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: forge-navbar-simple-centree
*<!-- wp:html -->
<header class="nav" data-nav>
<div class="nav__bar">
<a class="nav__brand" href="#accueil"><span class="nav__logo" aria-hidden="true"></span>Atelier Mercier</a>
<button type="button" class="nav__toggle" data-nav-toggle aria-expanded="false" aria-controls="nav-panel" aria-label="Menu">
<svg viewBox="0 0 24 24" aria-hidden="true"><path class="icon-open-navbar-simple-centree" d="M4 7h16M4 12h16M4 17h16"/><path class="icon-close-navbar-simple-centree" d="M6 6l12 12M18 6 6 18"/></svg>
</button>
<nav class="nav__panel" id="nav-panel" data-nav-panel aria-label="Navigation principale">
<ul class="nav__links">
<li><a class="nav__link" href="#accueil" aria-current="page">Accueil</a></li>
<li><a class="nav__link" href="#prestations">Prestations</a></li>
<li><a class="nav__link" href="#realisations">Réalisations</a></li>(() => {
if (!document.querySelector(".nav")) return;
document.querySelectorAll("[data-nav]").forEach((nav) => {
const toggle = nav.querySelector("[data-nav-toggle]");
const setOpen = (open) => {
nav.toggleAttribute("data-open", open);
toggle.setAttribute("aria-expanded", String(open));
};
toggle.addEventListener("click", () => setOpen(!nav.hasAttribute("data-open")));
nav.addEventListener("keydown", (event) => {
if (event.key === "Escape" && nav.hasAttribute("data-open")) {
setOpen(false);:root {
--nav-bg: #ffffff;
--nav-border: #e2e8f0;
--nav-text: #334155;
--nav-strong: #0f172a;
--nav-accent: #1d4ed8;
--nav-accent-text: #ffffff;
--nav-ring: #1d4ed8;
--demo-navbar-simple-centree-bg: #f8fafc;
--demo-navbar-simple-centree-text: #334155;
}
Free component: copy it freely, including for commercial projects.
Other navigation bars components in WordPress
Navigation bars components in WordPress
A navigation that sits at the bottom of the screen, under the thumb, on phones, and becomes a horizontal bar at the top on desktop.
- Tailwind
- React
- CSS
- WordPress

The house name in the middle, links split on each side, restaurant or designer-shop style.
- Tailwind
- React
- CSS
- WordPress

A strip of practical details (phone, opening hours) above the main navigation.
- Tailwind
- React
- CSS
- WordPress