Navbar

Documentation and examples for Bootstrap's powerful, responsive navigation header, the navbar. Includes support for branding, navigation, and more, including support for our collapse plugin.

How it works

Here’s what you need to know before getting started with the navbar:

  • Navbars require a wrapping .navbar with .navbar-expand{-sm|-md|-lg|-xl} for responsive collapsing and color scheme classes.
  • Navbars and their contents are fluid by default. Use optional containers to limit their horizontal width.
  • Use our spacing and flex utility classes for controlling spacing and alignment within navbars.
  • Navbars are responsive by default, but you can easily modify them to change that. Responsive behavior depends on our Collapse JavaScript plugin.
  • Navbars are hidden by default when printing. Force them to be printed by adding .d-print to the .navbar. See the display utility class.
  • Ensure accessibility by using a <nav> element or, if using a more generic element such as a <div>, add a role="navigation" to every navbar to explicitly identify it as a landmark region for users of assistive technologies.

Read on for an example and list of supported sub-components.

Navbar navigation links build on our .nav options with their own modifier class and require the use of toggler classes for proper responsive styling. Navigation in navbars will also grow to occupy as much horizontal space as possible to keep your navbar contents securely aligned.

Active states—with .active—to indicate the current page can be applied directly to .nav-links or their immediate parent .nav-items.

<nav class="navbar navbar-expand-lg bg-primary">
  <div class="container">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav">
        <li class="nav-item active">
          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Features</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Pricing</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#">Disabled</a>
        </li>
      </ul>
    </div>
  </div>
</nav>

You may also utilize dropdowns in your navbar nav. Dropdown menus require a wrapping element for positioning, so be sure to use separate and nested elements for .nav-item and .nav-link as shown below.

<nav class="navbar navbar-expand-lg bg-primary">
  <div class="container">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNavDropdown">
      <ul class="navbar-nav">
        <li class="nav-item active">
          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Features</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Pricing</a>
        </li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            Dropdown link
          </a>
          <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
          </div>
        </li>
      </ul>
    </div>
  </div>
</nav>

Forms

Place various form controls and components within a navbar with .form-inline.

<nav class="navbar navbar-expand-lg bg-primary">
    <div class="container">
        <div class="navbar-translate">
            <a class="navbar-brand" href="/presentation.html">Brand</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
                <span class="navbar-toggler-icon"></span>
                <span class="navbar-toggler-icon"></span>
            </button>
        </div>

        <div class="collapse navbar-collapse">
            <ul class="navbar-nav">
                <li class="nav-item active">
                    <a href="#pablo" class="nav-link">link</a>
                </li>
                <li class="nav-item">
                    <a href="#pablo" class="nav-link">link</a>
                </li>
            </ul>

            <form class="form-inline ml-auto" data-background-color>

                  <div class="input-group">
                    <div class="input-group-prepend">
                      <span class="input-group-text"><i class="now-ui-icons ui-1_email-85"></i></span>
                    </div>
                    <input type="text" class="form-control" placeholder="Your Email...">
                  </div>


            </form>
        </div>
    </div>
</nav>

Input groups work, too:

<nav class="navbar navbar-light bg-primary">
  <div class="container">
  <form class="form-inline mr-auto" data-background-color>
    <div class="input-group">
      <div class="input-group-prepend">
        <span class="input-group-text"><i class="now-ui-icons ui-1_email-85"></i></span>
      </div>
      <input type="text" class="form-control" placeholder="Your Email...">
    </div>
  </form>
  </div>
</nav>

How to enable Burger Menu

We created for you a class named .burger-menu and once it is applied to the tag body it will transform the navbar like it appears on the responsive mode and when you will open it will come from the right side or left side. To make open from left side please add the class .menu-on-left also on the body tag.

<!doctype html>
<html lang="en">
  <head>
    ...
  </head>
  <body class="burger-menu">
    ...
  </body>
</html>

To have the navbar with profile you must add on the li with .nav-item the class .nav-item-image and follow the same structure like in the example below:

<!-- Navbar with profile  -->
<nav class="navbar navbar-expand-lg bg-primary">
  <div class="container">
    <div class="navbar-translate">
      <a class="navbar-brand" href="#pablo">Navbar with profile</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#example-navbar-profile" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-bar bar1"></span>
        <span class="navbar-toggler-bar bar2"></span>
        <span class="navbar-toggler-bar bar3"></span>
      </button>
    </div>

    <div class="collapse navbar-collapse" id="example-navbar-profile">
      <ul class="navbar-nav ml-auto">
        <li class="nav-item active">
          <a class="nav-link" href="#pablo">
            <i class="now-ui-icons objects_globe"></i>
            <p>Discover</p>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#pablo">
            <i class="now-ui-icons users_circle-08"></i>
            <p>Profile</p>
          </a>
        </li>
        <li class="nav-item dropdown nav-item-image">
          <a href="#" class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown">
            <div class="">
              <img src="assets/img/avatar.jpg" alt="">
            </div>
          </a>
          <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
            <a class="dropdown-header">Dropdown header</a>
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
            <div class="divider"></div>
            <a class="dropdown-item" href="#">One more separated link</a>
          </div>
        </li>
      </ul>
    </div>
  </div>
</nav>
<!-- End Navbar with profile -->

To have the navbar with two .navbar-nav you have to put the id navbar-middle on the first navbar and on the last navbar you must put the id navbar-right like in the example below:

<!-- Navbar with profile  -->
<nav class="navbar navbar-expand-lg bg-primary">
  <div class="container">
    <div class="navbar-translate">
      <a class="navbar-brand" href="#pablo">Navbar with profile</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#example-navbar-profile" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-bar bar1"></span>
        <span class="navbar-toggler-bar bar2"></span>
        <span class="navbar-toggler-bar bar3"></span>
      </button>
    </div>

    <div class="collapse navbar-collapse" id="example-navbar-profile">
      <ul class="navbar-nav mx-auto" id="navbar-middle">
        <li class="nav-item active">
          <a class="nav-link" href="#pablo">
            <i class="now-ui-icons objects_globe"></i>
            <p>Discover</p>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#pablo">
            <i class="now-ui-icons users_circle-08"></i>
            <p>Profile</p>
          </a>
        </li>
        <li class="nav-item dropdown nav-item-image">
          <a href="#" class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown">
            <div class="">
              <img src="/assets/img/avatar.jpg" alt="">
            </div>
          </a>
          <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
            <a class="dropdown-header">Dropdown header</a>
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
            <div class="divider"></div>
            <a class="dropdown-item" href="#">One more separated link</a>
          </div>
        </li>
      </ul>
      <ul class="navbar-nav ml-auto" id="navbar-right">
        <li class="nav-item active">
          <a class="nav-link" href="#pablo">
            <i class="now-ui-icons objects_globe"></i>
            <p>Discover</p>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#pablo">
            <i class="now-ui-icons users_circle-08"></i>
            <p>Profile</p>
          </a>
        </li>
      </ul>
    </div>
  </div>
</nav>
<!-- End Navbar with profile -->

Color schemes

Theming the navbar has never been easier thanks to the combination of theming classes and background-color utilities. Choose from .navbar-light for use with light background colors, or .navbar-dark for dark background colors. Then, customize with .bg-* utilities.

<nav class="navbar navbar-expand-lg bg-primary">
  <!-- Navbar content -->
</nav>

<nav class="navbar navbar-expand-lg bg-info">
  <!-- Navbar content -->
</nav>

<nav class="navbar navbar-expand-lg bg-success">
  <!-- Navbar content -->
</nav>

<nav class="navbar navbar-expand-lg bg-warning">
  <!-- Navbar content -->
</nav>

<nav class="navbar navbar-expand-lg bg-danger">
  <!-- Navbar content -->
</nav>

<nav class="navbar navbar-dark navbar-transparent">
  <!-- Navbar content -->
</nav>

Containers

When the container is within your navbar, its horizontal padding is removed at breakpoints lower than your specified .navbar-expand{-sm|-md|-lg|-xl} class. This ensures we’re not doubling up on padding unnecessarily on lower viewports when your navbar is collapsed.

<nav class="navbar navbar-expand-lg navbar-light bg-primary">
  <div class="container">
    <a class="navbar-brand" href="#">Navbar</a>
  </div>
</nav>

Placement

Use our position utilities to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, or stickied to the top (scrolls with the page until it reaches the top, then stays there). Fixed navbars use position: fixed, meaning they’re pulled from the normal flow of the DOM and may require custom CSS (e.g., padding-top on the <body>) to prevent overlap with other elements.

Also note that .sticky-top uses position: sticky, which isn’t fully supported in every browser.

<nav class="navbar navbar-light bg-primary">
  <div class="container">
    <a class="navbar-brand" href="#">Default</a>
  </div>
</nav>
<nav class="navbar fixed-top navbar-light bg-primary">
  <div class="container">
    <a class="navbar-brand" href="#">Fixed top</a>
  </div>
</nav>
<nav class="navbar fixed-bottom navbar-light bg-primary">
  <div class="container">
    <a class="navbar-brand" href="#">Fixed bottom</a>
  </div>
</nav>
<nav class="navbar sticky-top navbar-light bg-primary">
  <div class="container">
    <a class="navbar-brand" href="#">Sticky top</a>
  </div>
</nav>

Responsive behaviors

Navbars can utilize .navbar-toggler, .navbar-collapse, and .navbar-expand{-sm|-md|-lg|-xl} classes to change when their content collapses behind a button. In combination with other utilities, you can easily choose when to show or hide particular elements.

For navbars that never collapse, add the .navbar-expand class on the navbar. For navbars that always collapse, don’t add any .navbar-expand class.

Toggler

Navbar togglers are left-aligned by default, but should they follow a sibling element like a .navbar-brand, they’ll automatically be aligned to the far right. Reversing your markup will reverse the placement of the toggler. Below are examples of different toggle styles.

With no .navbar-brand shown in lowest breakpoint:

<nav class="navbar navbar-expand-lg bg-primary">
  <div class="container">
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#example-navbar" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-bar bar1"></span>
      <span class="navbar-toggler-bar bar2"></span>
      <span class="navbar-toggler-bar bar3"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarTogglerDemo01">
      <a class="navbar-brand" href="#">Hidden brand</a>
      <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
        <li class="nav-item active">
          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#">Disabled</a>
        </li>
      </ul>
      <form class="form-inline ml-auto" data-background-color>
          <div class="form-group has-white">
            <input type="text" class="form-control" placeholder="Search">
          </div>
      </form>
    </div>
  </div>
</nav>

With a brand name shown on the left and toggler on the right:

<nav class="navbar navbar-expand-lg bg-primary">
  <div class="container">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#example-navbar" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-bar bar1"></span>
      <span class="navbar-toggler-bar bar2"></span>
      <span class="navbar-toggler-bar bar3"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
      <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
        <li class="nav-item active">
          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#">Disabled</a>
        </li>
      </ul>
      <form class="form-inline ml-auto" data-background-color>
          <div class="form-group has-white">
            <input type="text" class="form-control" placeholder="Search">
          </div>
      </form>
    </div>
  </div>
</nav>

With a toggler on the left and brand name on the right:

<nav class="navbar navbar-expand-lg bg-primary">
  <div class="container">
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#example-navbar" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-bar bar1"></span>
      <span class="navbar-toggler-bar bar2"></span>
      <span class="navbar-toggler-bar bar3"></span>
    </button>
    <a class="navbar-brand" href="#">Navbar</a>

    <div class="collapse navbar-collapse" id="navbarTogglerDemo03">
      <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
        <li class="nav-item active">
          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#">Disabled</a>
        </li>
      </ul>
      <form class="form-inline ml-auto" data-background-color>
          <div class="form-group has-white">
            <input type="text" class="form-control" placeholder="Search">
          </div>
      </form>
    </div>
  </div>
</nav>