Rate these docs

Vue Bootstrap Navbar

Vue Navbar - Bootstrap 4 & Material Design

Vue 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 don't require adding .navbar-expand{-sm|-md|-lg|-xl} classes for responsive collapsing. The .navbar-expand-lg class is added by defoult but you can easily change it by using expand prop. You can also use color scheme prop or classes.

  • Navbars and their contents are fluid by default. Use optional <mdb-container> to limit their horizontal width.

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

  • Navbars are responsive by default and you can easily modify them to change that.

  • <mdb-navbar> component by default is using nav element, but you can easily change it to more generic element such as a <div>, just add a tag="div" prop to every navbar

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 dark-themed navbar that automatically collapses at the lg (large) breakpoint.



        <!--Navbar-->
        <mdb-navbar class="indigo" dark>
          <!-- Navbar brand -->
          <mdb-navbar-brand href="https://mdbootstrap.com/">
            Navbar
          </mdb-navbar-brand>
          <mdb-navbar-toggler>
            <mdb-navbar-nav>
              <mdb-nav-item href="#" active>Home</mdb-nav-item>
              <mdb-nav-item href="#">Features</mdb-nav-item>
              <mdb-nav-item href="#">Pricing</mdb-nav-item>
              <!-- Dropdown -->
              <mdb-dropdown tag="li" class="nav-item">
                <mdb-dropdown-toggle tag="a" navLink color="indigo" slot="toggle" waves-fixed>Dropdown</mdb-dropdown-toggle>
                <mdb-dropdown-menu>
                  <mdb-dropdown-item>Action</mdb-dropdown-item>
                  <mdb-dropdown-item>Another action</mdb-dropdown-item>
                  <mdb-dropdown-item>Something else here</mdb-dropdown-item>
                </mdb-dropdown-menu>
              </mdb-dropdown>
            </mdb-navbar-nav>
            <!-- Search form -->
            <form class="form-inline">
              <input class="form-control mr-auto p-2" type="text" placeholder="Search" aria-label="Search">
            </form>
          </mdb-navbar-toggler>
        </mdb-navbar>
            
      

Color schemes

Theming the navbar has never been easier thanks to the combination of a color prop for Bootstrap utility classes and simple color classes. 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-->
          <mdb-navbar class="red">
            . . .
          </mdb-navbar>
          <!--/.Navbar red color-->
          
          <!--/.Navbar purple color-->
          <mdb-navbar color="primary">
            . . .
          </mdb-navbar>
          <!--/.Navbar purple color-->
          
          <!--/.Navbar green color-->
          <mdb-navbar class="green">
            . . .
          </mdb-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. For dark background use dark prop.


        <!--Navbar-->
        <mdb-navbar class="navbar-light blue-grey lighten-5">
          . . .
        </mdb-navbar>
        <!--/.Navbar-->
      

Supported content

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

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

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

  • for any form controls and actions.

  • <mdb-navbar-toggler> for grouping and hiding navbar contents by a parent breakpoint.

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

Brand

The <mdb-navbar-brand> component let you present your company, product, or project name. It can be used with href and tag props.



        <!--Navbar-->
        <mdb-navbar class="indigo" dark>
          <!-- Navbar brand -->
          <mdb-navbar-brand href="https://mdbootstrap.com/">
            Link
          </mdb-navbar-brand>
        </mdb-navbar>
            
      

Images

Adding images to the <mdb-navbar-brand> will likely always require custom styles or utilities to properly size. Here is example to demonstrate.



        <!--Navbar-->
        <mdb-navbar>
          <!-- Navbar brand -->
          <mdb-navbar-brand href="https://mdbootstrap.com/">
            <img src="https://mdbootstrap.com/img/logo/mdb-transparent.png" height="30" alt="">
          </mdb-navbar-brand>
        </mdb-navbar>

      

Nav

Navbar navigation links build on our <mdb-navbar> component require the use of <mdb-navbar-toggler> component 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 boolean prop indicate the current page can be applied directly to <mdb-nav-item> components.



        <!--Navbar-->
        <mdb-navbar class="indigo" dark>
          <!-- Navbar brand -->
          <mdb-navbar-brand href="#">
            Navbar
          </mdb-navbar-brand>
          <mdb-navbar-toggler>
            <mdb-navbar-nav>
              <mdb-nav-item href="#" class="active">Home</mdb-nav-item>
              <mdb-nav-item href="#">Features</mdb-nav-item>
              <mdb-nav-item href="#">Pricing</mdb-nav-item>
              <mdb-nav-item class="disabled" href="#">Disabled</mdb-nav-item>
            </mdb-navbar-nav>
          </mdb-navbar-toggler>
        </mdb-navbar>
            
      

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


        <mdb-navbar class="indigo" dark>
          <!-- Navbar brand -->
          <mdb-navbar-brand href="#">
            Navbar
          </mdb-navbar-brand>
          <mdb-navbar-toggler>
            <mdb-navbar-nav>
              <mdb-nav-item href="#" active> Home</mdb-nav-item>
              <mdb-nav-item href="#">Features</mdb-nav-item>
              <mdb-nav-item href="#">Pricing</mdb-nav-item>
              <mdb-dropdown tag="li" class="nav-item">
                <mdb-dropdown-toggle tag="a" navLink color="indigo" slot="toggle"  waves-fixed>Dropdown link</mdb-dropdown-toggle>
                <mdb-dropdown-menu>
                  <mdb-dropdown-item>Action</mdb-dropdown-item>
                  <mdb-dropdown-item>Another action</mdb-dropdown-item>
                  <mdb-dropdown-item>Something else here</mdb-dropdown-item>
                </mdb-dropdown-menu>
              </mdb-dropdown>
            </mdb-navbar-nav>
          </mdb-navbar-toggler>
        </mdb-navbar>
      

Forms

Place various form controls and components within a navbar with .form-inline class or <form-inline>component.


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

Heading

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


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

Input groups work, too:



        <mdb-navbar>
          <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>
        </mdb-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.


        <mdb-navbar>
          <form class="form-inline">
            <mdb-btn outline="success" size="lg" type="button">Search</mdb-btn>
            <mdb-btn outline="secondary" size="sm" type="button">Search</mdb-btn>
          </form>
        </mdb-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.


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

Mix and match with other components and utilities as needed.



        <mdb-navbar>
          <!-- Navbar brand -->
          <mdb-navbar-brand href="#">
            Navbar / text
          </mdb-navbar-brand>
          <mdb-navbar-toggler>
            <mdb-navbar-nav>
                <mdb-nav-item href="#" active>Home</mdb-nav-item>
                <mdb-nav-item href="#">Features</mdb-nav-item>
                <mdb-nav-item href="#">Pricing</mdb-nav-item>
            </mdb-navbar-nav>
            <span class="navbar-text">
                Navbar text with an inline element
            </span>
          </mdb-navbar-toggler>
        </mdb-navbar>
            
      

Containers

Although it’s not required, you can wrap a navbar in a <mdb-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

        <mdb-container>
          <mdb-navbar class="indigo">
            . . .
          </mdb-navbar>
        </mdb-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

        <mdb-navbar class="indigo">
          . . .
        </mdb-navbar>
      

Placement

Use our position prop 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

        <mdb-navbar position="top" class="indigo">
          . . .
        </mdb-navbar>
      

Fixed bottom

Live demo

        <mdb-navbar position="bottom" class="indigo">
          . . .
        </mdb-navbar>
      

Sticky top

Live demo

        <mdb-navbar position="sticky-top" class="indigo">
          . . .
        </mdb-navbar>
      

Responsive behaviors

Navbars can utilize expand prop to change when their content collapses behind a button. By adding small, medium, large you can easily choose when to show or hide particular elements.

Toggler

Navbar togglers are left-aligned by default, but should they follow a sibling element like a <mdb-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:



        <mdb-navbar expand="large" dark class="indigo">
          <!-- Navbar brand -->
          <mdb-navbar-brand href="#">
            Navbar
          </mdb-navbar-brand>
          <mdb-navbar-toggler>
              <mdb-navbar-nav>
                  <mdb-nav-item href="#" active>Home</mdb-nav-item>
                  <mdb-nav-item href="#">Link</mdb-nav-item>
                  <mdb-nav-item class="disabled" href="#">Disabled</mdb-nav-item>
              </mdb-navbar-nav>
          </mdb-navbar-toggler>
        </mdb-navbar>
            
      

Vue Bootstrap Navbar - API

In this section you will find advanced information about the Navbar component. You will find out which modules are required, what are the possibilities of configuring the component, and what events and methods you can use to work with it.


API Reference: mdbNavbar Properties

The table below shows the configuration options of the mdb-navbar component.

Name Type Default Description Example
tag String 'nav' Sets component's tag <mdb-navbar tag="div" />
animation String, Number <mdb-navbar animation="1" />
color String Sets navbars background color. Use our color palette <mdb-navbar color="indigo" />
dark Boolean false Adjusts font color to contrast with darker navbar color <mdb-navbar dark />
double Boolean false Makes the navbar a great feat with a SideNav <mdb-navbar double />
expand String 'small' Determines on which viewport navbar should be expanded. Accepts: sm / small, md / medium, lg / large. If empty - navbar will not collapse. <mdb-navbar expand="md" />
navIconClass String -- Set the toggler CSS class <mdb-navbar position="top" />
position String Setting the prop makes the navbar fixed. Accpeted values are "top" and "bottom" <mdb-navbar position="top" />
scrolling Boolean false Changes Navbar's size on scroll. Combine with prop transparent to achive color changing effect <mdb-navbar scrolling />
scrollingOffset Number 100 Represents the number of pixels scrolled vertically above which the 'scrolling' effect is applied <mdb-navbar :scrollingOffset={100} />
togglerClass String -- Helps to set custom styles on the hamburger wrapper <mdb-navbar :scrollingOffset={100} />
transparent Boolean false Sets Navbar background to transparent. Combine with prop scrolling and color props to achive color changing effect <mdb-navbar transparent />

API Reference: mdbNavbarBrand Properties

The table below shows the configuration options of the mdb-navbar-brand component.

Name Type Default Description Example
tag String 'a' Sets component's tag <mdb-navbar-brand tag="div" />
to String The prop turns the component into a router-link. Useful in case you would like to serve as a home button. <MDBNavbarBrand to="https://mdbootstrap.com/docs/vue/navigation/navbar/" />
waves Boolean Would you like some waves with that? <MDBNavbarBrand waves" />

API Reference: mdbNavbarNav Properties

The table below shows the configuration options of the mdb-navbar-nav component.

Name Type Default Description Example
tag String 'ul' Sets component's tag <mdb-navbar-nav tag="div" />
left Boolean false By default, the mdb-navbar-nav has its items scatter along the x axis with .justify-content-around .w-100. The props is used to gently pull them towards left <mdb-navbar-nav left />
right Boolean false Does the this as left, but does it right <mdb-navbar-nav right />

API Reference: mdbNavItem Properties

The table below shows the configuration options of the mdb-navbar-nav component.

Name Type Default Description Example
tag String 'li' Sets component's tag <mdb-navbar-brand tag="div" />
active Boolean false Sets NavItem's state to active <mdb-nav-item :active="chechIfActive" />
disabled Boolean false Turns the element link disabled <mdb-nav-item :disabled="AreYouDisabled" />
exact Boolean false Active class maching is inclusive. Use the prop to have the component turn into active state only when the href prop matches the $route.path exactly. Available for router propped component only <mdb-nav-item href="/" exact="AreYouDisabled" />
href String -- An outside URL a click should lead to <mdb-nav-item href="http://www.yeah.why.not.here" />
newTab Boolean false Used to have a page opened in a fresh browser's tab. Equivalent to good ol' target="_blank" anchor element attribute <mdb-nav-item :waves="false" />
to String -- Using this prop instead of href causes the component to render a router-link. Utilize it to navigate inside your SPA project. <mdb-nav-item :waves="false" />
waves Boolean false Sets up a wave effect upon clicking the component. Use wavesFixed prop in fixed elements instead <mdb-nav-item :waves="false" />

API Reference: mdbNavbarToggler Properties

The table below shows the configuration options of the mdbNavbarToggler component.

Name Type Default Description Example
tag String 'li' Sets component's tag <mdb-navbar-toggler tag="div" />