Skip to content

Mobile bottom tab bar 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.

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

Open in a new tab

The code in WordPress

navbar-onglets-bas-mobile.php
<?php
/**
 * Plugin Name: Forge, Barre d’onglets en bas sur mobile
 * Description: Une navigation qui se place en bas de l’écran, sous le pouce, sur téléphone, et redevient une barre horizontale en haut sur ordinateur. Ajoute la composition « Barre d’onglets en bas sur mobile » à 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-onglets-bas-mobile
 *
pattern.html
<!-- wp:html -->
<div class="nob" data-nob>
        <header class="nob-top">
          <p class="nob-brand">Pizzeria Nonna Rosa</p>
          <nav class="nob-nav" aria-label="Navigation principale">
            <ul class="nob-list">
            <li class="nob-li"><a class="nob-tab" href="#nob-accueil" data-nob-tab>
              <span class="nob-iconwrap"><svg class="nob-icon" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path d="M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z"/></svg></span>
              <span class="nob-label">Accueil</span>
            </a></li>
            <li class="nob-li"><a class="nob-tab" href="#nob-carte" aria-current="page" data-nob-tab>
              <span class="nob-iconwrap"><svg class="nob-icon" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path d="M6 3h12a1 1 0 0 1 1 1v16l-4-2-3 2-3-2-4 2V4a1 1 0 0 1 1-1zM9 8h6M9 12h6"/></svg></span>
script.js
(() => {
  if (!document.querySelector(".nob")) return;
  document.querySelectorAll("[data-nob]").forEach((root) => {
    const on = (el, type, fn) => el.addEventListener(type, fn);
    // Anchors stay on the page: mark the tab the visitor chose as the current one.
    root.querySelectorAll("[data-nob-tab]").forEach((tab, _, all) => {
      on(tab, "click", () => {
        all.forEach((other) => other.removeAttribute("aria-current"));
        tab.setAttribute("aria-current", "page");
      });
    });
  });
style.css
:root {
  --nob-bg: #fffaf3;
  --nob-text: #2a1d14;
  --nob-muted: #5e4c3e;
  --nob-bar: #ffffff;
  --nob-line: #eadfd2;
  --nob-accent: #b91c1c;
  --nob-active: #fdecec;
  --demo-navbar-onglets-bas-mobile-bg: #f4ede4;
  --demo-navbar-onglets-bas-mobile-text: #2a1d14;
}

Free component: copy it freely, including for commercial projects.

Navigation bars components in WordPress
  • Logo on the left, links in the middle, call to action on the right, collapsible menu on mobile.

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

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

    • Tailwind
    • React
    • CSS
    • WordPress
    Component