Navs

Create grouped navigation controls in various visual layouts.

Overview

Navigation share general markup and styles, from the base .nav class to the active and disabled states. Swap modifier classes to switch between each style.

Regarding Accessibility

If you are using navs to provide a navigation bar, be sure to add a role="navigation" to the most logical parent container of the <ul>, or wrap a <nav> element around the whole navigation. Do not add the role to the <ul> itself, as this would prevent it from being announced as an actual list by assistive technologies.

To convey the active state to assistive technologies, use the aria-current attribute — using the page value for current page, or true for the current item in a set.

Note that navigation bars, even if visually styled as tabs with the .nav-tabs class, should not be given role="tablist", role="tab" or role="tabpanel" attributes. These are only appropriate for dynamic tabbed interfaces, as described in the ARIA Authoring Practices Guide tab pattern. See our Tab widget for an example and additional details.

Disabling Anchors

Please refer to the Accessiblity notes about disabled anchors.

Base Nav

The base .nav component is built with flexbox and provides 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. No visual active states are included in the base nav.

<ul class="nav">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Classes are used throughout, so your markup can be super flexible. Use <ul>s like above, or roll your own with say 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 href="#" class="nav-link active" aria-current="page">Active</a>
<a href="#" class="nav-link">Link</a>
<a href="#" class="nav-link">Link</a>
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</nav>

Available Styles

Change the style of .nav components 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 .flex-center:

<ul class="nav flex-center">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Right-aligned with .flex-end:

<ul class="nav flex-end">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Vertical Alignment

Stack your navigation by changing the flex item direction with the .nav-vertical modifier or 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 nav-vertical">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

As always, vertical navigation is possible without <ul>s, too.

<nav class="nav flex-column">
<a href="#" class="nav-link active" aria-current="page">Active</a>
<a href="#" class="nav-link">Link</a>
<a href="#" class="nav-link">Link</a>
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</nav>

Pills

Take that same HTML, but use .nav-pills instead:

<ul class="nav nav-pills">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" 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. Use them to create tabbable regions with our Tab JavaScript widget.

<ul class="nav nav-tabs">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Flip the tabs upside down by adding .nav-reverse to the .nav.

<ul class="nav nav-tabs nav-reverse">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Lined

Take that same HTML, but use .nav-lined instead:

<ul class="nav nav-lined">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Move the line to the top of the lined nav links by adding .nav-reverse to the .nav.

<ul class="nav nav-lined nav-reverse">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Vertical Pills

Add .nav-vertical modifier, or .flex-column utility, to the .nav.nav-pills to stack them vertically. Each .nav-link becomes block-level, allowing for larger hit areas.

<ul class="nav nav-pills nav-vertical">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

As always, vertical pills are possible without <ul>s.

<nav class="nav nav-pills flex-column">
<a href="#" class="nav-link active" aria-current="page">Active</a>
<a href="#" class="nav-link">Link</a>
<a href="#" class="nav-link">Link</a>
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</nav>

Vertical Tabs

Add .nav-vertical modifier to the .nav.nav-tabs to stack them vertically. Each .nav-link becomes block-level, allowing for larger hit areas.

<ul class="nav nav-tabs nav-vertical" style="max-width: 15rem;">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

As always, vertical tabs are possible without <ul>s.

<nav class="nav nav-tabs nav-vertical" style="max-width: 15rem;">
<a href="#" class="nav-link active" aria-current="page">Active</a>
<a href="#" class="nav-link">Link</a>
<a href="#" class="nav-link">Link</a>
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</nav>

The direction of the tabs can be swapped by adding .nav-reverse to the .nav.

<ul class="nav nav-tabs nav-vertical nav-reverse" style="max-width: 15rem;">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Vertical Lined

Add .nav-vertical modifier to the .nav.nav-lined to stack them vertically. Each .nav-link becomes block-level, allowing for larger hit areas.

<ul class="nav nav-lined nav-vertical border-e" style="max-width: 15rem;">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

As always, vertical lined nav links are possible without <ul>s.

<nav class="nav nav-lined nav-vertical border-e" style="max-width: 15rem;">
<a href="#" class="nav-link active" aria-current="page">Active</a>
<a href="#" class="nav-link">Link</a>
<a href="#" class="nav-link">Link</a>
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</nav>

The side the lines appear on can be swapped by adding .nav-reverse to the .nav.

<ul class="nav nav-lined nav-vertical nav-reverse border-s" style="max-width: 15rem;">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Fill and Justify

Force your .nav’s contents to extend the full available width with one of two modifier classes. To proportionately fill all available space with your .nav-items, 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 href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Much longer nav link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

For equal-width elements, use .nav-justify. All horizontal space will be occupied by nav links, but unlike the .nav-fill above, every nav item will be the same width.

<ul class="nav nav-pills nav-justify">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Much longer nav link</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Similar to the .nav-fill example using a <nav>-based navigation.

<nav class="nav nav-pills nav-justify">
<a href="#" class="nav-link active" aria-current="page">Active</a>
<a href="#" class="nav-link">Much longer nav link</a>
<a href="#" class="nav-link">Link</a>
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</nav>

Working with Flex Utilities

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, the 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-column flex-sm-row">
<a href="#" class="flex-sm-fill text-sm-center nav-link active" aria-current="page">Active</a>
<a href="#" class="flex-sm-fill text-sm-center nav-link">Longer nav ink</a>
<a href="#" class="flex-sm-fill text-sm-center nav-link">Link</a>
<a class="flex-sm-fill text-sm-center nav-link disabled" aria-disabled="true">Disabled</a>
</nav>

Using Dropdowns

Add dropdown menus with a little extra HTML and the Dropdown JavaScript widget.

Incompatible Widgets

For accessibility reasons, do not mix use of the Tab widget and Dropdown widget in the same nav item. This will cause navigation and usability issues. One or the other, but not both.

From a usability perspective, the example where the currently displayed tab's trigger element might not immediately visible (as it could be inside a closed dropdown menu) would cause confusion. From an accessibility point of view, there is currently no sensible way to map this sort of construct to a standard WAI ARIA pattern, meaning that it cannot be easily made understandable to users of assistive technologies.

Tabs with Dropdowns

<ul class="nav nav-tabs">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item dropdown">
<a href="#" role="button" class="nav-link" data-cfw="dropdown">Dropdown<span class="caret" aria-hidden="true"></span></a>
<ul class="dropdown-menu">
<li><a href="#" class="dropdown-item">Action</a></li>
<li><a href="#" class="dropdown-item">Another action</a></li>
<li><a href="#" class="dropdown-item">Something else here</a></li>
<li class="dropdown-divider"></li>
<li><a href="#" class="dropdown-item">Separated link</a></li>
</ul>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

Pills with Dropdowns

<ul class="nav nav-pills">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">Active</a>
</li>
<li class="nav-item dropdown">
<a href="#" role="button" class="nav-link" data-cfw="dropdown">Dropdown<span class="caret" aria-hidden="true"></span></a>
<ul class="dropdown-menu">
<li><a href="#" class="dropdown-item">Action</a></li>
<li><a href="#" class="dropdown-item">Another action</a></li>
<li><a href="#" class="dropdown-item">Something else here</a></li>
<li class="dropdown-divider"></li>
<li><a href="#" class="dropdown-item">Separated link</a></li>
</ul>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>

SASS Reference

Variables

The available Customization options, or Sass variables, that can be customized for nav components.

Name Type Default Description
$enable-nav boolean true Enable the generation of the nav classes. Smaller segements of the nav classes can be disabled with the following $enable-* variables.
$enable-nav-tabs boolean true Enable the generation of tab nav styles.
$enable-nav-pills boolean true Enable the generation of pill nav styles.
$enable-nav-lined boolean true Enable the generation of lined nav styles.
$enable-nav-vertical boolean true Enable the generation of vertical nav styles.
$enable-nav-reverse boolean true Enable the generation of reverse nav styles.
$enable-nav-fill boolean true Enable the generation of fill alignment nav style.
$enable-nav-justify boolean true Enable the generation of justify alignment nav style.
$enable-tab-content boolean true Enable the generation of tab content pane visibility styles.
$nav-link-padding-y string .3125rem Vertical padding for nav links.
$nav-link-padding-x string 1rem Horizontal padding for nav links.
$nav-link-font-size string null Font size for base nav links.
$nav-link-font-weight string null Font weight for base nav links.
$nav-link-color string $link-color Text color for base nav links.
$nav-link-decoration string if($link-decoration == none, null, none) Text decoration for base nav links.
$nav-link-hover-color string $link-hover-color Text color for base nav links in hover or focus state.
$nav-link-hover-decoration string if($link-hover-decoration == underline, none, null) Text decoration for base nav links in hover or focus state.
$nav-link-disabled-opacity string .6 Opacity for disabled nav links.
$nav-link-disabled-color string .6 Text color for disabled nav links.
$nav-link-transition string color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out Transition for navs links.
$nav-tabs-border-color string $component-border-color Border color for tab navs.
$nav-tabs-border-width string $border-width Border width for tab navs.
$nav-tabs-hover-border-color string $component-hover-bg Border color for tab navs in hover or focus state.
$nav-tabs-hover-bg string $component-hover-bg Background color for tab navs in hover or focus state.
$nav-tabs-hover-color string null Text color for tab navs in hover or focus state.
$nav-tabs-active-bg string $body-bg Background color for tab navs in active state.
$nav-tabs-active-color string $component-action-color Text color for tab navs in active state.
$nav-tabs-active-border-color string $component-border-color Border color for tab navs in active state.
$nav-pills-border-radius string $border-radius Border radius for pill navs.
$nav-pills-hover-bg string $component-hover-bg Background color for pill navs in hover or focus state.
$nav-pills-hover-color string null Text color for pill navs in hover or focus state.
$nav-pills-active-bg string $component-active-bg Background color for pill navs in active state.
$nav-pills-active-color string $component-active-color Text color for pill navs in active state.
$nav-lined-gap string 1rem Gap for lined nav when in horzontal mode.
$nav-lined-border-width string .125rem Border thickness for lined nav.
$nav-lined-active-color string $component-action-color Text color for lined navs in active state.

Mixins

No mixins available.