Documentation and examples for how to use Bootstrap’s included navigation components.
Read the official
Bootstrap Documentation for a full list of instructions
and
other options.
Bootstrap includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.
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.
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
Change the style of .nav
s component with modifiers and utilities. Mix and match as needed, or
build
your own.
Horizontal Alignment
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
:
<ul class="nav justify-content-center">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
Right-aligned with .justify-content-end
:
<ul class="nav justify-content-end">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
Vertical
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
).
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
Tabs
Takes the basic nav from above and adds the .nav-tabs
class to generate a tabbed interface.
<ul class="nav nav-tabs">
<li class="nav-item">
<button class="nav-link active" data-bs-toggle="javascript:void(0)">Active</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-toggle="javascript:void(0)" tabindex="-1" aria-disabled="true">Disabled</button>
</li>
</ul>
Pills
Take that same HTML, but use .nav-pills
instead:
<ul class="nav nav-pills">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)" tabindex="-1" aria-disabled="true">Disabled</button>
</li>
</ul>
Tabs Line
Take that same HTML, but use .tabs-line
class along with .nav-tabs
:
<ul class="nav nav-tabs tabs-line">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)" tabindex="-1" aria-disabled="true">Disabled</button>
</li>
</ul>
Fill and justify
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 .nav-fill
. Notice
that
all horizontal space is occupied, but not every nav item has the same width.
<nav class="nav nav-pills nav-fill">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Much longer nav link</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)" tabindex="-1" aria-disabled="true">Disabled</button>
</li>
</nav>
Larger or smaller navs? Add .nav-lg
or .nav-sm
for additional sizes.
<!-- Large -->
<ul class="nav nav-lg nav-tabs">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)">Disabled</button>
</li>
</ul>
<ul class="nav nav-lg nav-pills">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)">Disabled</button>
</li>
</ul>
<ul class="nav nav-lg nav-tabs tabs-line">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)">Disabled</button>
</li>
</ul>
<!-- Small -->
<ul class="nav nav-sm nav-tabs">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)">Disabled</button>
</li>
</ul>
<ul class="nav nav-sm nav-pills">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)">Disabled</button>
</li>
</ul>
<ul class="nav nav-sm nav-tabs tabs-line">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link </button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)">Disabled</button>
</li>
</ul>
Class | Value |
---|---|
class="nav nav-{value}"
|
lg | sm |
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.
<nav class="nav nav-pills flex-sm-nowrap flex-column flex-sm-row">
<button class="flex-sm-fill text-sm-center nav-link active" data-bs-target="javascript:void(0)">Active</button>
<button class="flex-sm-fill text-sm-center nav-link" data-bs-target="javascript:void(0)">Longer nav link</button>
<button class="flex-sm-fill text-sm-center nav-link" data-bs-target="javascript:void(0)">Link</button>
<button class="flex-sm-fill text-sm-center nav-link disabled" data-bs-target="javascript:void(0)" tabindex="-1" aria-disabled="true">Disabled</button>
</nav>
Add dropdown menus with a little extra HTML and the dropdowns JavaScript plugin.
Tabs with dropdowns
<ul class="nav nav-tabs">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active</button>
</li>
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" data-bs-target="#" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">Action</a>
<a class="dropdown-item" href="javascript:void(0)">Another action</a>
<a class="dropdown-item" href="javascript:void(0)">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="javascript:void(0)">Separated link</a>
</div>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)" tabindex="-1" aria-disabled="true">Disabled</button>
</li>
</ul>
Pills with dropdowns
<ul class="nav nav-pills">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active</button>
</li>
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" data-bs-target="#" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">Action</a>
<a class="dropdown-item" href="javascript:void(0)">Another action</a>
<a class="dropdown-item" href="javascript:void(0)">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="javascript:void(0)">Separated link</a>
</div>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)" tabindex="-1" aria-disabled="true">Disabled</button>
</li>
</ul>
Tabs Line with dropdowns
<ul class="nav nav-tabs tabs-line">
<li class="nav-item">
<button class="nav-link active" data-bs-target="javascript:void(0)">Active</button>
</li>
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" data-bs-target="#" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">Action</a>
<a class="dropdown-item" href="javascript:void(0)">Another action</a>
<a class="dropdown-item" href="javascript:void(0)">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="javascript:void(0)">Separated link</a>
</div>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-target="javascript:void(0)">Link</button>
</li>
<li class="nav-item">
<button class="nav-link disabled" data-bs-target="javascript:void(0)" tabindex="-1" aria-disabled="true">Disabled</button>
</li>
</ul>