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.
  • Add an optional .navbar-scroll to set a max-height and scroll expanded navbar content.

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 - 图1

  1. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Navbar</a>
  4. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  5. <span class="navbar-toggler-icon"></span>
  6. </button>
  7. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  8. <ul class="navbar-nav me-auto mb-2 mb-lg-0">
  9. <li class="nav-item">
  10. <a class="nav-link active" aria-current="page" href="#">Home</a>
  11. </li>
  12. <li class="nav-item">
  13. <a class="nav-link" href="#">Link</a>
  14. </li>
  15. <li class="nav-item dropdown">
  16. <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
  17. Dropdown
  18. </a>
  19. <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
  20. <li><a class="dropdown-item" href="#">Action</a></li>
  21. <li><a class="dropdown-item" href="#">Another action</a></li>
  22. <li><hr class="dropdown-divider"></li>
  23. <li><a class="dropdown-item" href="#">Something else here</a></li>
  24. </ul>
  25. </li>
  26. <li class="nav-item">
  27. <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
  28. </li>
  29. </ul>
  30. <form class="d-flex">
  31. <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
  32. <button class="btn btn-outline-success" type="submit">Search</button>
  33. </form>
  34. </div>
  35. </div>
  36. </nav>

This example uses background (bg-light) and spacing (my-2, my-lg-0, me-sm-0, my-sm-0) utility classes.

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.

Text

Add your text within an element with the .navbar-brand class.

Navbar - 图2

  1. <!-- As a link -->
  2. <nav class="navbar navbar-light bg-light">
  3. <div class="container-fluid">
  4. <a class="navbar-brand" href="#">Navbar</a>
  5. </div>
  6. </nav>
  7. <!-- As a heading -->
  8. <nav class="navbar navbar-light bg-light">
  9. <div class="container-fluid">
  10. <span class="navbar-brand mb-0 h1">Navbar</span>
  11. </div>
  12. </nav>

Image

You can replace the text within the .navbar-brand with an <img>.

Navbar - 图3

  1. <nav class="navbar navbar-light bg-light">
  2. <div class="container">
  3. <a class="navbar-brand" href="#">
  4. <img src="/docs/5.0/assets/brand/bootstrap-logo.svg" alt="" width="30" height="24">
  5. </a>
  6. </div>
  7. </nav>

Image and text

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 - 图4

  1. <nav class="navbar navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">
  4. <img src="/docs/5.0/assets/brand/bootstrap-logo.svg" alt="" width="30" height="24" class="d-inline-block align-text-top">
  5. Bootstrap
  6. </a>
  7. </div>
  8. </nav>

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.

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.

Navbar - 图5

  1. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Navbar</a>
  4. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
  5. <span class="navbar-toggler-icon"></span>
  6. </button>
  7. <div class="collapse navbar-collapse" id="navbarNav">
  8. <ul class="navbar-nav">
  9. <li class="nav-item">
  10. <a class="nav-link active" aria-current="page" href="#">Home</a>
  11. </li>
  12. <li class="nav-item">
  13. <a class="nav-link" href="#">Features</a>
  14. </li>
  15. <li class="nav-item">
  16. <a class="nav-link" href="#">Pricing</a>
  17. </li>
  18. <li class="nav-item">
  19. <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
  20. </li>
  21. </ul>
  22. </div>
  23. </div>
  24. </nav>

And because we use classes for our navs, you can avoid the list-based approach entirely if you like.

Navbar - 图6

  1. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Navbar</a>
  4. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
  5. <span class="navbar-toggler-icon"></span>
  6. </button>
  7. <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
  8. <div class="navbar-nav">
  9. <a class="nav-link active" aria-current="page" href="#">Home</a>
  10. <a class="nav-link" href="#">Features</a>
  11. <a class="nav-link" href="#">Pricing</a>
  12. <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
  13. </div>
  14. </div>
  15. </div>
  16. </nav>

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.

Navbar - 图7

  1. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Navbar</a>
  4. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
  5. <span class="navbar-toggler-icon"></span>
  6. </button>
  7. <div class="collapse navbar-collapse" id="navbarNavDropdown">
  8. <ul class="navbar-nav">
  9. <li class="nav-item">
  10. <a class="nav-link active" aria-current="page" href="#">Home</a>
  11. </li>
  12. <li class="nav-item">
  13. <a class="nav-link" href="#">Features</a>
  14. </li>
  15. <li class="nav-item">
  16. <a class="nav-link" href="#">Pricing</a>
  17. </li>
  18. <li class="nav-item dropdown">
  19. <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
  20. Dropdown link
  21. </a>
  22. <ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
  23. <li><a class="dropdown-item" href="#">Action</a></li>
  24. <li><a class="dropdown-item" href="#">Another action</a></li>
  25. <li><a class="dropdown-item" href="#">Something else here</a></li>
  26. </ul>
  27. </li>
  28. </ul>
  29. </div>
  30. </div>
  31. </nav>

Forms

Place various form controls and components within a navbar:

Navbar - 图8

  1. <nav class="navbar navbar-light bg-light">
  2. <div class="container-fluid">
  3. <form class="d-flex">
  4. <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
  5. <button class="btn btn-outline-success" type="submit">Search</button>
  6. </form>
  7. </div>
  8. </nav>

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.

Navbar - 图9

  1. <nav class="navbar navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand">Navbar</a>
  4. <form class="d-flex">
  5. <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
  6. <button class="btn btn-outline-success" type="submit">Search</button>
  7. </form>
  8. </div>
  9. </nav>

Input groups work, too. If your navbar is an entire form, or mostly a form, you can use the <form> element as the container and save some HTML.

Navbar - 图10

  1. <nav class="navbar navbar-light bg-light">
  2. <form class="container-fluid">
  3. <div class="input-group">
  4. <span class="input-group-text" id="basic-addon1">@</span>
  5. <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
  6. </div>
  7. </form>
  8. </nav>

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 - 图11

  1. <nav class="navbar navbar-light bg-light">
  2. <form class="container-fluid justify-content-start">
  3. <button class="btn btn-outline-success me-2" type="button">Main button</button>
  4. <button class="btn btn-sm btn-outline-secondary" type="button">Smaller button</button>
  5. </form>
  6. </nav>

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 - 图12

  1. <nav class="navbar navbar-light bg-light">
  2. <div class="container-fluid">
  3. <span class="navbar-text">
  4. Navbar text with an inline element
  5. </span>
  6. </div>
  7. </nav>

Mix and match with other components and utilities as needed.

Navbar - 图13

  1. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Navbar w/ text</a>
  4. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
  5. <span class="navbar-toggler-icon"></span>
  6. </button>
  7. <div class="collapse navbar-collapse" id="navbarText">
  8. <ul class="navbar-nav me-auto mb-2 mb-lg-0">
  9. <li class="nav-item">
  10. <a class="nav-link active" aria-current="page" href="#">Home</a>
  11. </li>
  12. <li class="nav-item">
  13. <a class="nav-link" href="#">Features</a>
  14. </li>
  15. <li class="nav-item">
  16. <a class="nav-link" href="#">Pricing</a>
  17. </li>
  18. </ul>
  19. <span class="navbar-text">
  20. Navbar text with an inline element
  21. </span>
  22. </div>
  23. </div>
  24. </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.

Navbar - 图14

  1. <nav class="navbar navbar-dark bg-dark">
  2. <!-- Navbar content -->
  3. </nav>
  4. <nav class="navbar navbar-dark bg-primary">
  5. <!-- Navbar content -->
  6. </nav>
  7. <nav class="navbar navbar-light" style="background-color: #e3f2fd;">
  8. <!-- Navbar content -->
  9. </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.

Navbar - 图15

  1. <div class="container">
  2. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  3. <div class="container-fluid">
  4. <a class="navbar-brand" href="#">Navbar</a>
  5. </div>
  6. </nav>
  7. </div>

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

Navbar - 图16

  1. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  2. <div class="container-md">
  3. <a class="navbar-brand" href="#">Navbar</a>
  4. </div>
  5. </nav>

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.

Navbar - 图17

  1. <nav class="navbar navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Default</a>
  4. </div>
  5. </nav>

Navbar - 图18

  1. <nav class="navbar fixed-top navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Fixed top</a>
  4. </div>
  5. </nav>

Navbar - 图19

  1. <nav class="navbar fixed-bottom navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Fixed bottom</a>
  4. </div>
  5. </nav>

Navbar - 图20

  1. <nav class="navbar sticky-top navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Sticky top</a>
  4. </div>
  5. </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.

Navbar - 图21

  1. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Navbar scroll</a>
  4. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarScroll" aria-controls="navbarScroll" aria-expanded="false" aria-label="Toggle navigation">
  5. <span class="navbar-toggler-icon"></span>
  6. </button>
  7. <div class="collapse navbar-collapse" id="navbarScroll">
  8. <ul class="navbar-nav me-auto my-2 my-lg-0 navbar-nav-scroll" style="--bs-scroll-height: 100px;">
  9. <li class="nav-item">
  10. <a class="nav-link active" aria-current="page" href="#">Home</a>
  11. </li>
  12. <li class="nav-item">
  13. <a class="nav-link" href="#">Link</a>
  14. </li>
  15. <li class="nav-item dropdown">
  16. <a class="nav-link dropdown-toggle" href="#" id="navbarScrollingDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
  17. Link
  18. </a>
  19. <ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown">
  20. <li><a class="dropdown-item" href="#">Action</a></li>
  21. <li><a class="dropdown-item" href="#">Another action</a></li>
  22. <li><hr class="dropdown-divider"></li>
  23. <li><a class="dropdown-item" href="#">Something else here</a></li>
  24. </ul>
  25. </li>
  26. <li class="nav-item">
  27. <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Link</a>
  28. </li>
  29. </ul>
  30. <form class="d-flex">
  31. <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
  32. <button class="btn btn-outline-success" type="submit">Search</button>
  33. </form>
  34. </div>
  35. </div>
  36. </nav>

Responsive behaviors

Navbars can use .navbar-toggler, .navbar-collapse, and .navbar-expand{-sm|-md|-lg|-xl|-xxl} classes to determine 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 no .navbar-brand shown at the smallest breakpoint:

Navbar - 图22

  1. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  2. <div class="container-fluid">
  3. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
  4. <span class="navbar-toggler-icon"></span>
  5. </button>
  6. <div class="collapse navbar-collapse" id="navbarTogglerDemo01">
  7. <a class="navbar-brand" href="#">Hidden brand</a>
  8. <ul class="navbar-nav me-auto mb-2 mb-lg-0">
  9. <li class="nav-item">
  10. <a class="nav-link active" aria-current="page" href="#">Home</a>
  11. </li>
  12. <li class="nav-item">
  13. <a class="nav-link" href="#">Link</a>
  14. </li>
  15. <li class="nav-item">
  16. <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
  17. </li>
  18. </ul>
  19. <form class="d-flex">
  20. <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
  21. <button class="btn btn-outline-success" type="submit">Search</button>
  22. </form>
  23. </div>
  24. </div>
  25. </nav>

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

Navbar - 图23

  1. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  2. <div class="container-fluid">
  3. <a class="navbar-brand" href="#">Navbar</a>
  4. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
  5. <span class="navbar-toggler-icon"></span>
  6. </button>
  7. <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
  8. <ul class="navbar-nav me-auto mb-2 mb-lg-0">
  9. <li class="nav-item">
  10. <a class="nav-link active" aria-current="page" href="#">Home</a>
  11. </li>
  12. <li class="nav-item">
  13. <a class="nav-link" href="#">Link</a>
  14. </li>
  15. <li class="nav-item">
  16. <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
  17. </li>
  18. </ul>
  19. <form class="d-flex">
  20. <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
  21. <button class="btn btn-outline-success" type="submit">Search</button>
  22. </form>
  23. </div>
  24. </div>
  25. </nav>

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

Navbar - 图24

  1. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  2. <div class="container-fluid">
  3. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
  4. <span class="navbar-toggler-icon"></span>
  5. </button>
  6. <a class="navbar-brand" href="#">Navbar</a>
  7. <div class="collapse navbar-collapse" id="navbarTogglerDemo03">
  8. <ul class="navbar-nav me-auto mb-2 mb-lg-0">
  9. <li class="nav-item">
  10. <a class="nav-link active" aria-current="page" href="#">Home</a>
  11. </li>
  12. <li class="nav-item">
  13. <a class="nav-link" href="#">Link</a>
  14. </li>
  15. <li class="nav-item">
  16. <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
  17. </li>
  18. </ul>
  19. <form class="d-flex">
  20. <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
  21. <button class="btn btn-outline-success" type="submit">Search</button>
  22. </form>
  23. </div>
  24. </div>
  25. </nav>

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!

Navbar - 图25

  1. <div class="collapse" id="navbarToggleExternalContent">
  2. <div class="bg-dark p-4">
  3. <h5 class="text-white h4">Collapsed content</h5>
  4. <span class="text-muted">Toggleable via the navbar brand.</span>
  5. </div>
  6. </div>
  7. <nav class="navbar navbar-dark bg-dark">
  8. <div class="container-fluid">
  9. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
  10. <span class="navbar-toggler-icon"></span>
  11. </button>
  12. </div>
  13. </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.

Sass

Variables

  1. $navbar-padding-y: $spacer / 2;
  2. $navbar-padding-x: null;
  3. $navbar-nav-link-padding-x: .5rem;
  4. $navbar-brand-font-size: $font-size-lg;
  5. // Compute the navbar-brand padding-y so the navbar-brand will have the same height as navbar-text and nav-link
  6. $nav-link-height: $font-size-base * $line-height-base + $nav-link-padding-y * 2;
  7. $navbar-brand-height: $navbar-brand-font-size * $line-height-base;
  8. $navbar-brand-padding-y: ($nav-link-height - $navbar-brand-height) / 2;
  9. $navbar-brand-margin-end: 1rem;
  10. $navbar-toggler-padding-y: .25rem;
  11. $navbar-toggler-padding-x: .75rem;
  12. $navbar-toggler-font-size: $font-size-lg;
  13. $navbar-toggler-border-radius: $btn-border-radius;
  14. $navbar-toggler-focus-width: $btn-focus-width;
  15. $navbar-toggler-transition: box-shadow .15s ease-in-out;
  1. $navbar-dark-color: rgba($white, .55);
  2. $navbar-dark-hover-color: rgba($white, .75);
  3. $navbar-dark-active-color: $white;
  4. $navbar-dark-disabled-color: rgba($white, .25);
  5. $navbar-dark-toggler-icon-bg: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'><path stroke='#{$navbar-dark-color}' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/></svg>");
  6. $navbar-dark-toggler-border-color: rgba($white, .1);
  7. $navbar-light-color: rgba($black, .55);
  8. $navbar-light-hover-color: rgba($black, .7);
  9. $navbar-light-active-color: rgba($black, .9);
  10. $navbar-light-disabled-color: rgba($black, .3);
  11. $navbar-light-toggler-icon-bg: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'><path stroke='#{$navbar-light-color}' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/></svg>");
  12. $navbar-light-toggler-border-color: rgba($black, .1);
  13. $navbar-light-brand-color: $navbar-light-active-color;
  14. $navbar-light-brand-hover-color: $navbar-light-active-color;
  15. $navbar-dark-brand-color: $navbar-dark-active-color;
  16. $navbar-dark-brand-hover-color: $navbar-dark-active-color;

Loop

Responsive navbar expand/collapse classes (e.g., .navbar-expand-lg) are combined with the $breakpoints map and generated through a loop in scss/_navbar.scss.

  1. // Generate series of `.navbar-expand-*` responsive classes for configuring
  2. // where your navbar collapses.
  3. .navbar-expand {
  4. @each $breakpoint in map-keys($grid-breakpoints) {
  5. $next: breakpoint-next($breakpoint, $grid-breakpoints);
  6. $infix: breakpoint-infix($next, $grid-breakpoints);
  7. // stylelint-disable-next-line scss/selector-no-union-class-name
  8. &#{$infix} {
  9. @include media-breakpoint-up($next) {
  10. flex-wrap: nowrap;
  11. justify-content: flex-start;
  12. .navbar-nav {
  13. flex-direction: row;
  14. .dropdown-menu {
  15. position: absolute;
  16. }
  17. .nav-link {
  18. padding-right: $navbar-nav-link-padding-x;
  19. padding-left: $navbar-nav-link-padding-x;
  20. }
  21. }
  22. .navbar-nav-scroll {
  23. overflow: visible;
  24. }
  25. .navbar-collapse {
  26. display: flex !important; // stylelint-disable-line declaration-no-important
  27. flex-basis: auto;
  28. }
  29. .navbar-toggler {
  30. display: none;
  31. }
  32. }
  33. }
  34. }
  35. }