Here’s what you need to know before getting started with the navbar:
Navbars come with built-in support for a handful of sub-components. Choose from the following as needed:
Here’s an example of all the sub-components included in a responsive light-themed navbar that automatically collapses at the lg (large) breakpoint.
This example uses background (bg-body-tertiary) and spacing (me-auto, mb-2, mb-lg-0, me-2) utility classes.
The .navbar-brand can be applied to most elements, but an anchor works best, as some elements might require utility classes or custom styles.
Add your text within an element with the .navbar-brand class.
You can replace the text within the .navbar-brand with an .
You can also make use of some additional utilities to add an image and text at the same time. Note the addition of .d-inline-block and .align-text-top on the < img>.
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.
Add the .active class on .nav-link to indicate the current page.
Please note that you should also add the aria-current attribute on the active .nav-link.
And because we use classes for our navs, you can avoid the list-based approach entirely if you like.
You can also use dropdowns in your navbar. 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.
Place various form controls and components within a navbar:
Immediate child elements of .navbar use flex layout and will default to justify-content: space-between. Use additional flex utilities as needed to adjust this behavior.
Input groups work, too. If your navbar is an entire form, or mostly a form, you can use the