Sign in


Sign up


Bootstrap Navbar

Bootstrap navbar is a horizontal navigation component which apart from traditional, text links, might embed icons, dropdowns, avatars or search forms.

MDB provides you with stylish Navbars, with distinctive for Material Design details (such as shadows, living colors or charming wave effects triggered by clicking on the link). Apart from traditional, text links, Bootstraps Navbar might embed regular & social icons, dropdowns, avatars or search forms.

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.

  • Navbars and their contents are built with flexbox, providing easy alignment options via utility classes.

  • Navbars are responsive by default, but you can easily modify them to change that. Responsive behavior depends on our Collapse JavaScript plugin.

  • 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.


Basic example

Here’s an example of all the sub-components included in a responsive light-themed navbar that automatically collapses at the lg (large) breakpoint.

                
<navbar className="indigo" name="Navbar" href="#"> 
  <navbar-collapse> 
    <navbar-nav> 
      <navbar-item href="#" active>Home</navbar-item> 
      <navbar-item href="#">Features</navbar-item> 
      <navbar-item href="#">Pricing</navbar-item> 
      <dropdown tag="li" class="nav-item">
        <dropdown-toggle tag="a" navLink color="indigo" waves-fixed>Dropdown</dropdown-toggle>
        <dropdown-menu>
          <dropdown-item>Action</dropdown-item>
          <dropdown-item>Another action</dropdown-item>
          <dropdown-item>Something else here</dropdown-item>
        </dropdown-menu>
      </dropdown>
    </navbar-nav> 
    <form class="form-inline"> 
      <input class="form-control mr-auto p-2" type="text" placeholder="Search" aria-label="Search"> 
    </form> 
  </navbar-collapse> 
</navbar>
            

Color schemes

Theming the navbar has never been easier thanks to the combination of a simple link color modifier class and background-color utilities. Put another way, you specify light or dark and apply a background color.

You can choose one of over 300 colors form our material palette.



                
<!--/.Navbar red color-->                                
<navbar className="red">
...
</navbar>
<!--/.Navbar red color-->

<!--/.Navbar purple color-->                                
<navbar className="purple">
...
</navbar>
<!--/.Navbar purple color-->

<!--/.Navbar green color-->                                
<navbar className="green">
...
</navbar>
<!--/.Navbar green color-->
            

If you want to use light background you should apply .navbar-light class to the Navbar, to provide a proper contrast for links.

                    
<!--Navbar-->
<navbar className="navbar-light blue-grey lighten-5">
    [..]
</navbar>
<!--/.Navbar-->
                    

Supported content

Navbars come with built-in support for a handful of sub-components. Choose from the following as needed:

  • .navbar-brand for your company, product, or project name.

  • .navbar-nav for a full-height and lightweight navigation (including support for dropdowns).

  • .navbar-toggler for use with our collapse plugin and other navigation toggling behaviors.

  • .form-inline for any form controls and actions.

  • .navbar-text for adding vertically centered strings of text.

  • .collapse.navbar-collapse for grouping and hiding navbar contents by a parent breakpoint.

Brand

The .navbar-brand can be applied to most elements, but an anchor works best as some elements might require utility classes or custom styles.

                
<!-- As a link -->
<navbar name="Link" href="#">
    [..]
</nav>
                

Images

Adding images to the .navbar-brand will likely always require custom styles or utilities to properly size. Here are some examples to demonstrate.

                
<!--Navbar-->
<navbar src="https://mdbootstrap.com/img/logo/mdb-transparent.png" alt="Brand logo">
    [..]
</navbar>
<!--/.Navbar-->
                

                
<!--Navbar-->
<navbar src="https://mdbootstrap.com/img/logo/mdb-transparent.png" alt="Brand logo" name="Bootstrap">
    [..]
</navbar>
<!--/.Navbar-->
            

Nav

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 the active attribute—to indicate the current page can be applied directly to navbar-item components.

                
<navbar className="indigo" name="Navbar" href="#"> 
  <navbar-collapse> 
    <navbar-nav> 
      <navbar-item href="#" active>Home</navbar-item> 
      <navbar-item href="#">Features</navbar-item> 
      <navbar-item href="#">Pricing</navbar-item> 
      <navbar-item className="disabled" href="#">Disabled</navbar-item> 
    </navbar-nav> 
  </navbar-collapse> 
</navbar>
                

You may also utilize dropdowns in your navbar. To do so, simply include the dropdown component, as shown below.

                
<navbar className="indigo" name="Navbar" href="#"> 
  <navbar-collapse> 
    <navbar-nav> 
      <navbar-item href="#" active> Home</navbar-item> 
      <navbar-item href="#">Features</navbar-item> 
      <navbar-item href="#">Pricing</navbar-item> 
      <dropdown tag="li" class="nav-item">
        <dropdown-toggle tag="a" navLink color="indigo" waves-fixed>Dropdown</dropdown-toggle>
        <dropdown-menu>
          <dropdown-item>Action</dropdown-item>
          <dropdown-item>Another action</dropdown-item>
          <dropdown-item>Something else here</dropdown-item>
        </dropdown-menu>
      </dropdown>
    </navbar-nav> 
  </navbar-collapse> 
</navbar>
                

Forms

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

                
<navbar> 
    <form class="form-inline">
        <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
        <btn outline="success" size="sm" className="my-0" type="submit">Search</btn>
    </form>
</navbar>
                

Heading

Align the contents of your inline forms with utilities as needed.


<navbar name="Navbar" href="#"> 
    <form class="form-inline">
        <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
        <btn outline="success" size="sm" className="my-0" type="submit">Search</btn>
    </form>
</navbar>

Input groups work, too:

                
<navbar className="indigo"> 
    <form class="form-inline">                
        <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">@</span>
            <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
        </div>
    </form>
</navbar>
                

Various buttons are supported as part of these navbar forms, too. This is also a great reminder that vertical alignment utilities can be used to align different sized elements.

                
<navbar> 
    <form class="form-inline">
        <btn outline="success" size="lg" type="button">Search</btn>
        <btn outline="secondary" size="sm" type="button">Search</btn>
    </form>
</navbar>
                

Text

Navbars may contain bits of text with the help of .navbar-text. This class adjusts vertical alignment and horizontal spacing for strings of text.

                
<navbar> 
    <span class="navbar-text white-text">
        Navbar text with an inline element
    </span>
</navbar>
                

Mix and match with other components and utilities as needed.

                
<navbar className="indigo" name="Navbar / text" href="#"> 
  <navbar-collapse> 
    <navbar-nav> 
      <navbar-item href="#" active>Home</navbar-item> 
      <navbar-item href="#">Features</navbar-item> 
      <navbar-item href="#">Pricing</navbar-item> 
    </navbar-nav> 
    <span class="navbar-text white-text">
        Navbar text with an inline element
    </span>   
  </navbar-collapse> 
</navbar>
                

Containers

Although it’s not required, you can wrap a navbar in a .container to center it on a page or add one within to only center the contents of a fixed or static top navbar

Live demo
            
<container>                
    <navbar className="indigo" name="Navbar" href="#"> 
    </navbar>
</container>
        

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.

Live demo
            
<navbar className="indigo" name="Navbar" href="#"> 
</navbar>
        

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. Note that position: sticky, used for .sticky-top, isn’t fully supported in every browser.

Fixed top

Live demo
        
<navbar position="top" className="indigo" name="Navbar" href="#"> 
</navbar>
        

Fixed bottom

Live demo
            
<navbar position="bottom" className="indigo" name="Navbar" href="#"> 
</navbar>
            

Sticky top

Live demo
            
<navbar className="sticky-top, indigo" name="Navbar" href="#"> 
</navbar>
            

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 a brand name shown on the left and toggler on the right:

                
<navbar expand="large" className="indigo" name="Navbar" href="#"> 
  <navbar-collapse> 
    <navbar-nav> 
      <navbar-item href="#" active>Home</navbar-item> 
      <navbar-item href="#">Link</navbar-item> 
      <navbar-item className="disabled" href="#">Disabled</navbar-item> 
    </navbar-nav>    
  </navbar-collapse>
</navbar>