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

Bootstrap Navbar documentation

## 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|-xxl}` for responsive collapsing and color scheme classes.
- Navbars and their contents are fluid by default. Change the container to limit their horizontal width in different ways.
- 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.
- 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

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.
- Flex and spacing utilities 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.

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

                          <nav class="navbar navbar-expand-lg navbar-light bg-gray-100">
                            <div class="container-fluid">
                              <a class="navbar-brand" href="#0">Navbar</a>
                              <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                                <span class="navbar-toggler-icon"></span>
                              </button>
                              <div class="collapse navbar-collapse" id="navbarSupportedContent">
                                <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link1</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link2</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link3</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link4</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link5</a>
                                  </li>
                                </ul>
                              </div>
                            </div>
                          </nav>

                          <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
                            <div class="container-fluid">
                              <a class="navbar-brand" href="#0">Navbar</a>
                              <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                                <span class="navbar-toggler-icon"></span>
                              </button>
                              <div class="collapse navbar-collapse" id="navbarSupportedContent">
                                <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link1</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link2</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link3</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link4</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link5</a>
                                  </li>
                                </ul>
                              </div>
                            </div>
                          </nav>

## 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 navbar-dark bg-dark">
                            <div class="container-fluid">
                              <a class="navbar-brand" href="#">Navbar</a>
                              <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
                                <span class="navbar-toggler-icon"></span>
                              </button>
                              <div class="collapse navbar-collapse" id="navbarColor01">
                                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                                  <li class="nav-item">
                                    <a class="nav-link active" aria-current="page" href="#">Home</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" href="#">About</a>
                                  </li>
                                </ul>
                                <form class="d-flex">
                                  <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
                                  <button class="btn btn-outline-light" type="submit">Search</button>
                                </form>
                              </div>
                            </div>
                          </nav>
                          <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
                            <div class="container-fluid">
                              <a class="navbar-brand" href="#">Navbar</a>
                              <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation">
                                <span class="navbar-toggler-icon"></span>
                              </button>
                              <div class="collapse navbar-collapse" id="navbarColor02">
                                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                                  <li class="nav-item">
                                    <a class="nav-link active" aria-current="page" href="#">Home</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" href="#">About</a>
                                  </li>
                                </ul>
                                <form class="d-flex">
                                  <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
                                  <button class="btn btn-outline-light" type="submit">Search</button>
                                </form>
                              </div>
                            </div>
                          </nav>
                          <nav class="navbar navbar-expand-lg navbar-light" style="background-color: #e3f2fd;">
                            <div class="container-fluid">
                              <a class="navbar-brand" href="#">Navbar</a>
                              <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor03" aria-controls="navbarColor03" aria-expanded="false" aria-label="Toggle navigation">
                                <span class="navbar-toggler-icon"></span>
                              </button>
                              <div class="collapse navbar-collapse" id="navbarColor03">
                                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                                  <li class="nav-item">
                                    <a class="nav-link active" aria-current="page" href="#">Home</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" href="#">About</a>
                                  </li>
                                </ul>
                                <form class="d-flex">
                                  <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
                                  <button class="btn btn-outline-primary" type="submit">Search</button>
                                </form>
                              </div>
                            </div>
                          </nav>

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

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

## 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 fixed-top navbar-light bg-gray-100">
                            <div class="container-fluid">
                              <a class="navbar-brand" href="#0">Fixed top</a>
                            </div>
                          </nav>

                          <nav class="navbar fixed-bottom navbar-light bg-gray-100">
                            <div class="container-fluid">
                              <a class="navbar-brand" href="#0">Fixed bottom</a>
                            </div>
                          </nav>

                          <nav class="navbar sticky-top navbar-light bg-gray-100">
                            <div class="container-fluid">
                              <a class="navbar-brand" href="#0">Sticky top</a>
                            </div>
                          </nav>

## Scrolling

Add `.navbar-nav-scroll` to a `.navbar-nav` (or other navbar sub-component) to enable vertical scrolling within the toggleable contents of a collapsed navbar. By default, scrolling kicks in at `75vh` (or 75% of the viewport height), but you can override that with the local CSS custom property `--bs-navbar-height` or custom styles. At larger viewports when the navbar is expanded, content will appear as it does in a default navbar.

Please note that this behavior comes with a potential drawback of `overflow`—when setting `overflow-y: auto` (required to scroll the content here), `overflow-x` is the equivalent of `auto`, which will crop some horizontal content.

Here’s an example navbar using `.navbar-nav-scroll` with `style="--bs-scroll-height: 100px;"`, with some extra margin utilities for optimum spacing.

                          <nav class="navbar navbar-expand-lg navbar-light bg-light">
                            <div class="container-fluid">
                              <a class="navbar-brand" href="#">Navbar scroll</a>
                              <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarScroll" aria-controls="navbarScroll" aria-expanded="false" aria-label="Toggle navigation">
                                <span class="navbar-toggler-icon"></span>
                              </button>
                              <div class="collapse navbar-collapse" id="navbarScroll">
                                <ul class="navbar-nav me-auto my-2 my-lg-0 navbar-nav-scroll" style="--bs-scroll-height: 100px;">
                                  <li class="nav-item">
                                    <a class="nav-link active" aria-current="page" href="#">Home</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#">Link</a>
                                  </li>
                                  <li class="nav-item dropdown">
                                    <a class="nav-link dropdown-toggle" href="#" id="navbarScrollingDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                                      Link
                                    </a>
                                    <ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown">
                                      <li><a class="dropdown-item" href="#">Action</a></li>
                                      <li><a class="dropdown-item" href="#">Another action</a></li>
                                      <li><hr class="dropdown-divider"></li>
                                      <li><a class="dropdown-item" href="#">Something else here</a></li>
                                    </ul>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Link</a>
                                  </li>
                                </ul>
                                <form class="d-flex">
                                  <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
                                  <button class="btn btn-outline-success" type="submit">Search</button>
                                </form>
                              </div>
                            </div>
                          </nav>

## Responsive behaviors

Navbars can utilize `.navbar-toggler`, `.navbar-collapse`, and `.navbar-expand{-sm|-md|-lg|-xl|-xxl}` 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.

                          <nav class="navbar navbar-expand-lg navbar-light bg-light">
                            <div class="container-fluid">
                              <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
                                <span class="navbar-toggler-icon"></span>
                              </button>
                              <div class="collapse navbar-collapse" id="navbarTogglerDemo01">
                                <a class="navbar-brand" href="#0">Hidden brand</a>
                                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                                  <li class="nav-item">
                                    <a class="nav-link active" aria-current="page" href="#0">Home</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link disabled" href="#0" tabindex="-1" aria-disabled="true">Disabled</a>
                                  </li>
                                </ul>
                                <form class="d-flex">
                                  <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
                                  <button class="btn btn-outline-success" type="submit">Search</button>
                                </form>
                              </div>
                            </div>
                          </nav>

## External content

Sometimes you want to use the collapse plugin to trigger hidden content elsewhere on the page. Because our plugin works on the `id` and `data-target` matching, that’s easily done!

##### Collapsed content

Toggleable via the navbar brand.

                          <nav class="navbar navbar-expand-lg navbar-light bg-light">
                            <div class="container-fluid">
                              <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
                                <span class="navbar-toggler-icon"></span>
                              </button>
                              <div class="collapse navbar-collapse" id="navbarTogglerDemo01">
                                <a class="navbar-brand" href="#0">Hidden brand</a>
                                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                                  <li class="nav-item">
                                    <a class="nav-link active" aria-current="page" href="#0">Home</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" href="#0">Link</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link disabled" href="#0" tabindex="-1" aria-disabled="true">Disabled</a>
                                  </li>
                                </ul>
                                <form class="d-flex">
                                  <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
                                  <button class="btn btn-outline-success" type="submit">Search</button>
                                </form>
                              </div>
                            </div>
                          </nav>

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.