Skip to docs navigation

Navbar

Notes

  • 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.
  • Indicate the current item by using aria-current="page" for the current page or aria-current="true" for the current item in a set.
The animation effect of this component is dependent on the prefers-reduced-motion media query. See the reduced motion section of our accessibility documentation.

Supported content

Choose from the following as needed:

  • .navbar-brand
  • .navbar-nav
  • .navbar-toggler
  • .navbar-text
  • .collapse.navbar-collapse

Here’s an example using all the sub-components.

Brand

Adding images to the .navbar-brand will likely always require custom styles.

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

Please note that you should also add the aria-current attribute on the .nav-link itself.

Please note that you should also add the `aria-current` attribute on the `.nav-link` itself.

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.

Forms

Place various form controls and components within a navbar:

Using additional flex utilities.

Input groups work, too.

Various buttons are supported as part of a navbar form, too.

Text

Navbars may contain bits of text with the help of .navbar-text.

Mix and match with other components and utilities as needed.

Color schemes

Choose from .navbar-light for use with light background colors, or .navbar-dark for dark background colors. Then, customize with .bg-* utilities.

Containers

Although it’s not required, you can wrap a navbar in a .container to center it on a page–though note that an inner container is still required. Or you can add a container inside the .navbar to only center the contents of a fixed or static top navbar.

Use any of the responsive containers to change how wide the content in your navbar is presented.

Placement

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

Responsive behaviors

Use .navbar-toggler, .navbar-collapse, and .navbar-expand{-sm|-md|-lg|-xl|-xxl} classes to determine when their content collapses behind a button.

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

No .navbar-brand shown at the smallest breakpoint:

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

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

External content

Sometimes you want to use the collapse plugin to trigger a container element for content that structurally sits outside of the .navbar . Because our plugin works on the id and data-bs-target matching, that’s easily done!

When you do this, we recommend including additional JavaScript to move the focus programmatically to the container when it is opened. Otherwise, keyboard users and users of assistive technologies will likely have a hard time finding the newly revealed content - particularly if the container that was opened comes before the toggler in the document’s structure. We also recommend making sure that the toggler has the aria-controls attribute, pointing to the id of the content container. In theory, this allows assistive technology users to jump directly from the toggler to the container it controls–but support for this is currently quite patchy.