Bootstrap Menu

This is another usage of the Navbar initialized to the menu itself, just like in the Left Menu demo, but this time we're using the original Bootstrap Navbar wrapper and markup. This is like a hybrid usage of the Navbar with the least possible CSS redundancy.

Demo Highlights

Bootstrap Navbar Wrapper

<nav class="navbar navbar-dark bg-dark">
  <a class="navbar-brand" href="#">Navbar</a>
  <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-wrapper">
    <span class="navbar-toggler-icon"></span>
  </button>
      
  <div id="navbar-wrapper" class="navbar-collapse collapse">
    <ul class="navbar-nav me-auto" data-function="navbar" data-breakpoint="768" data-toggle-siblings="true">
      <li class="nav-item"><a class="nav-link" href="#">Root Menu Item</a></li>
      <li class="nav-item active">
        <a class="nav-link" href="#">
          Parent Menu Item
          <i class="parent-icon"></i>
        </a>
        <button class="subnav-toggle">
          <i class="menu-icon"/>
        </button>        
        <ul class="subnav">
          <li class="nav-item active"><a class="nav-link" href="#">Submenu Item 1</a></li>
          <li class="nav-item"><a class="nav-link" href="#">Submenu Item 2</a></li>
        </ul>
      </li>
    </ul>
    <span class="navbar-text">
      <a href="#">Some link</a> and other text.
    </span>
  </div>
</nav>

As you can see we're using the original plugin markup and functionality with the collapsible element, as well as the .navbar-nav class for the menu itself, the .nav-item and .nav-link classes for menu items and .navbar-text class for other contents.

Bootstrap Menu Mixins

// navbar-bootstrap.scss - mixins
@import 'variables','mixins','mixins-bs','root';

@include navbar-style-bs;
@include nav-layout-bs;
@include main-menu-bs;

Used CSS Variables

// bootstrap.html - custom CSS variable values
.navbar {
  --nv-padding-x: 1rem;
  --nv-padding-y: .5rem;
  --nv-subnav-padding-x: .5rem;
  --nv-subnav-padding-y: .5rem;
}

More Demos

This is the reason for this implementation, the large amount of flexibility and utilities from Bootstrap, the functionality and additions from Navbar. There is another demo we've set up, a demo in which we're using Navbar with the full markup and styling, something that might look like an extended version of the original Bootstrap component.

A quick note on the usage of mega menu: the Bootstrap grid also allows you to set a breakpoint for your columns, so make sure to double check the Navbar options.breakpoint, SCSS $responsive-breakpoint and your column col-BREAKPOINT-3 class.

thednp © 2024 Go back to top