Bootstrap Tabs and Pills: Creating Interactive Navigation and Content Organization
Learn how to use Bootstrap's tabs and pills for creating user-friendly and visually appealing navigation elements. This guide provides examples of creating horizontal and vertical tabs and pills, customizing their appearance, and integrating them effectively into your web designs.
Bootstrap Tabs and Pills: Creating Interactive Navigation
Bootstrap provides pre-styled components for creating tabs and pills—elements that make navigation easier and more visually appealing. This guide covers various Bootstrap menu styles and customizations.
Bootstrap Menus
Basic horizontal menus are easily created using Bootstrap's classes. Simply add the `.list-inline` class to an unordered list (`
- `) for a horizontal arrangement.
- `, and `.nav-link` to the links. You can control alignment (left, center, right) and create vertical menus using additional classes.
Horizontal Alignment
- Default: Left-aligned
- Center: Add `.justify-content-center`
- Right: Add `.justify-content-end`
Vertical Nav Menu
Add the `.flex-column` class to make a vertical navigation menu.
Justified Tabs/Pills
Use the `.nav-justified` class for equal-width tabs or pills.
Bootstrap Tabs
Bootstrap tabs provide a way to organize content into sections, allowing users to switch between them. You can easily mark the active tab.
Tabs with Dropdown Menus
You can incorporate dropdown menus within your tabs for more complex navigation.
Dynamic/Toggleable Tabs
To create interactive tabs, add the `data-toggle="tab"` attribute to each tab link, wrap the tab content in a `
Bootstrap Pills
Pills are similar to tabs but have a rounder appearance. They function similarly to tabs.
Vertical Pills
Add the `.nav-stacked` class to display pills vertically.
Pills with Dropdown Menus
Just like tabs, pills can also include dropdown menus.
Dynamic/Toggleable Pills
For interactive pills, use `data-toggle="pill"` instead of `data-toggle="tab"`. The implementation is otherwise the same as with dynamic tabs.
Bootstrap 4 Nav Menus
Bootstrap provides flexible nav menus. Add the `.nav` class to a `
- `, `.nav-item` to each `