Navs
Documentation and examples for how to use navigation components.
Basic
<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>
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.
<nav class= "nav" >
<a class= "nav-link active" href= "#" > Active</a>
<a class= "nav-link" href= "#" > Link</a>
<a class= "nav-link" href= "#" > Link</a>
<a class= "nav-link disabled" href= "#" tabindex= "-1" aria-disabled= "true" > Disabled</a>
</nav>
Options
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>
As always, vertical navigation is possible without <ul>
s, too.
<nav class= "nav flex-column" >
<a class= "nav-link active" href= "#" > Active</a>
<a class= "nav-link" href= "#" > Link</a>
<a class= "nav-link" href= "#" > Link</a>
<a class= "nav-link disabled" href= "#" tabindex= "-1" aria-disabled= "true" > Disabled</a>
</nav>
Types
Tabs
Takes the basic nav from above and adds the .nav-tabs
class to generate a tabbed interface. Use them to create tabbable regions with our tab JavaScript plugin .
<ul class= "nav nav-tabs" >
<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>
Pills
Take that same HTML, but use .nav-pills
instead:
<ul class= "nav nav-pills" >
<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>
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.
<ul class= "nav nav-pills nav-fill" >
<li class= "nav-item" >
<a class= "nav-link active" href= "#" > Active</a>
</li>
<li class= "nav-item" >
<a class= "nav-link" href= "#" > Longer nav 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>
When using a <nav>
-based navigation, be sure to include .nav-item
on the anchors.
<nav class= "nav nav-pills nav-fill" >
<a class= "nav-item nav-link active" href= "#" > Active</a>
<a class= "nav-item nav-link" href= "#" > Link</a>
<a class= "nav-item nav-link" href= "#" > Link</a>
<a class= "nav-item nav-link disabled" href= "#" tabindex= "-1" aria-disabled= "true" > Disabled</a>
</nav>
For equal-width elements, use .nav-justified
. All horizontal space will be occupied by nav links, but unlike the .nav-fill
above, every nav item will be the same width.
<nav class= "nav nav-pills nav-justified" >
<a class= "nav-link active" href= "#" > Active</a>
<a class= "nav-link" href= "#" > Longer nav link</a>
<a class= "nav-link" href= "#" > Link</a>
<a class= "nav-link disabled" href= "#" tabindex= "-1" aria-disabled= "true" > Disabled</a>
</nav>
Similar to the .nav-fill
example using a <nav>
-based navigation, be sure to include .nav-item
on the anchors.
<nav class= "nav nav-pills nav-justified" >
<a class= "nav-item nav-link active" href= "#" > Active</a>
<a class= "nav-item nav-link" href= "#" > Link</a>
<a class= "nav-item nav-link" href= "#" > Link</a>
<a class= "nav-item nav-link disabled" href= "#" tabindex= "-1" aria-disabled= "true" > Disabled</a>
</nav>
Examples
Icon pills
<nav class= "nav nav-pills nav-pills-icon nav-justified" >
<a class= "nav-item nav-link py-3 active" href= "#" >
<span class= "d-block" >
<i class= "far fa-ethernet fa-2x" ></i>
</span>
<span class= "d-none d-sm-block mt-2" > Active pill</span>
</a>
<a class= "nav-item nav-link py-3" href= "#" >
<span class= "d-block" >
<i class= "far fa-save fa-2x" ></i>
</span>
<span class= "d-none d-sm-block mt-2" > Link</span>
</a>
<a class= "nav-item nav-link py-3" href= "#" >
<span class= "d-block" >
<i class= "far fa-satellite fa-2x" ></i>
</span>
<span class= "d-none d-sm-block mt-2" > Link</span>
</a>
</nav>
Circle pills
<ul class= "nav nav-pills nav-pills-circle nav-justified" >
<li class= "nav-item" >
<a class= "nav-link active" href= "#" >
<i class= "far fa-ethernet fa-2x" ></i>
</a>
</li>
<li class= "nav-item" >
<a class= "nav-link" href= "#" >
<i class= "far fa-save fa-2x" ></i>
</a>
</li>
<li class= "nav-item" >
<a class= "nav-link" href= "#" >
<i class= "far fa-satellite fa-2x" ></i>
</a>
</li>
</ul>
You can add a connection line by adding the .nav-pills-connect
modifier class.
<ul class= "nav nav-pills nav-pills-circle nav-pills-connect nav-justified" >
<li class= "nav-item" >
<a class= "nav-link active" href= "#" >
<i class= "far fa-ethernet fa-2x" ></i>
</a>
</li>
<li class= "nav-item" >
<a class= "nav-link" href= "#" >
<i class= "far fa-save fa-2x" ></i>
</a>
</li>
<li class= "nav-item" >
<a class= "nav-link" href= "#" >
<i class= "far fa-satellite fa-2x" ></i>
</a>
</li>
</ul>