Tabs and Pills – Bootstrap


Tabs and Pills

Tabs and Pills are forms of navigation. Meaning they help the end-user navigate through the site in a user-friendly manner.

Tabs

To achieve bootstrap tabs, first you need an element that has the .nav class assigned to it. Then you simply add an extra class named .nav-tabs.

<ul class="nav nav-tabs"> <li role="presentation" class="active"><a href="#">Home</a></li> <li role="presentation"><a href="#">Profile</a></li> <li role="presentation"><a href="#">Messages</a></li> </ul>

Bootstrap Tabs

Pills

Bootstrap Pills is achieved the same way as Bootstrap Tabs except instead of .nav-tabs, use .nav-pills.

<ul class="nav nav-pills"> <li role="presentation" class="active"><a href="#">Home</a></li> <li role="presentation"><a href="#">Profile</a></li> <li role="presentation"><a href="#">Messages</a></li> </ul>

Bootstrap Pills

Pills Stacked

Bootstrap Pills are also vertically stackable by using .nav stacked in conjunction with .nav-pills.

<ul class="nav nav-pills nav-stacked"> ... </ul>

Bootstrap Pills Stacked

Bootstrap Tabs/Pills Justified

Both Bootstrap Tabs and Pills can have equal width of their parent at screens wider than 768px by using .nav-justified class. On smaller screens, the nav links are stacked.

<ul class="nav nav-tabs nav-justified"> ... </ul> <ul class="nav nav-pills nav-justified"> ... </ul>

Bootstrap Tabs/Pills Justified

Disabled Links

For any nav component (tabs or pills) add .disabled for gray links and no hover effects

<ul class="nav nav-pills"> ... <li role="presentation" class="disabled"><a href="#">Disabled link</a></li> ... </ul>

Disabled Links

Tabs with Dropdowns

Add dropdown menus to your nav tabs.

<ul class="nav nav-tabs"> ... <li role="presentation" class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"> Dropdown <span class="caret"></span> </a> <ul class="dropdown-menu"> ... </ul> </li> ... </ul>

Tabs with Dropdowns

Tabs with Dropdowns

Add dropdown menus to your nav pills.

<ul class="nav nav-pills"> ... <li role="presentation" class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"> Dropdown <span class="caret"></span> </a> <ul class="dropdown-menu"> ... </ul> </li> ... </ul>
Pills with Dropdowns

More Information

This article needs improvement. You can help improve this article. You can also write similar articles and help the community.