The base .nav
component is built with flexbox and provide a strong foundation for building all types of navigation components. It includes some style overrides (for working with lists), some link padding for larger hit areas, and basic disabled styling.
Classes are used throughout, so your markup can be super flexible. Use <ul>
s like above, <ol>
if the order of your items is important, or roll your own with a <nav>
element. Because the .nav uses display: flex, the nav links behave the same as nav items would, but without the extra markup.
Change the horizontal alignment of your nav with flexbox utilities. By default, navs are left-aligned, but you can easily change them to center or right aligned.
Centered with .justify-content-center
:
Right-aligned with .justify-content-end
:
Stack your navigation by changing the flex item direction with the .flex-column
utility. Need to stack them on some viewports but not others? Use the responsive versions (e.g., .flex-sm-column
).
Takes the basic nav from above and adds the variant="tabs"
class to generate a tabbed interface
Take that same HTML, but use variant="pills"
instead:
Force your .nav
's contents to extend the full available width one of two modifier classes. To proportionately fill all available space with your .nav-item
s, use layout="fill"
. Notice that all horizontal space is occupied, but not every nav item has the same width.
For equal-width elements, use layout="justified"
. All horizontal space will be occupied by nav links, but unlike the .nav-fill above, every nav item will be the same width.
If you need responsive nav variations, consider using a series of flexbox utilities. While more verbose, these utilities offer greater customization across responsive breakpoints. In the example below, our nav will be stacked on the lowest breakpoint, then adapt to a horizontal layout that fills the available width starting from the small breakpoint.