The Wayback Machine - https://web.archive.org/web/20241117145400/https://www.geeksforgeeks.org/bootstrap-dropdowns-and-responsive-tabs/
Open In App

Bootstrap DropDowns and Responsive Tabs

Last Updated : 20 Feb, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow
  1. Introduction and Installation
  2. Grid System
  3. Buttons, Glyphicons, Tables
  4. Vertical Forms, Horizontal Forms, Inline Forms
  5. Progress Bar and Jumbotron

Dropdown Menu Using Bootstrap:

In bootstrap, dropdowns are created using the class=”dropdown”. What we will do is create a button and then convert the button into a dropdown.
As already stated in the last few tutorials, buttons can be created using the <button> tag. But in this button, we want to create a dropdown, so we will add the class=”btn dropdown-toggle” and data-toggle=”dropdown”.

Basically, it would look something like this.

<button class=”btn btn-default dropdown-toggle” type=”button” data-toggle=”dropdown”> My Dropdown </button>

Note: data- toggle attribute has been replaced with data-bs-toggle in Bootstrap. So, to run the below code with Bootstrap 5 makes sure to replace data-toggle with data-bs-toggle.

Now we want to convert this button into a dropdown. So, we’ll create an unordered list using the <ul> tag having class=”dropdown-menu” and add items using the <li> tag.

Example: 

HTML




<!DOCTYPE html>
<html lang="en">
<head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
</head>
<body>
    <div class="container" style="color:green">
        <h1>GeeksforGeeks</h1>
    </div>
    <div class="container">
        <h4>Dropdown in Bootstrap</h4>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-md-3">
                <div class="dropdown">
                    <button class="btn btn-success dropdown-toggle"
                        type="button" data-toggle="dropdown">
                        GeeksforGeeks
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="#">HTML</a></li>
                        <li><a href="#">CSS</a></li>
                        <li><a href="#">JavaScript</a></li>
                        <li><a href="#">SQL</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</body>
</html>


Output:

 Bootstrap DropDowns and Responsive Tabs

You can make your dropdown better by using classes in the <li> tag. To add a header in a dropdown add class=”dropdown-header”, to add a divider between items, use class=”divider” and to disable an item in the list, use class=”disabled”.

Example: 

HTML




<!DOCTYPE html>
<html lang="en">
<head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
</head>
<body>
    <div class="container" style="color:green">
        <h1>GeeksforGeeks</h1>
    </div>
    <div class="container">
        <h4>Dropdown in Bootstrap</h4>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-md-3">
                <div class="dropdown">
                    <button class="btn btn-success dropdown-toggle"
                        type="button" data-toggle="dropdown">
                        GeeksforGeeks
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <li class="dropdown-header container">
                            <b>HTML</b>
                        </li>
                        <li><a href="#">CSS</a></li>
                        <li><a href="#">JS</a></li>
                        <li class="divider"></li>
                        <li class="dropdown-header container">
                            <b>Language</b>
                        </li>
                        <li><a href="#"></a></li>
                        <li><a href="#">Python</a></li>
                        <li><a href="#">SQL</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</body>
</html>


Output:

 

Navigation Tabs using Bootstrap:

To create a tabbed navigation menu, we need to make an unordered list using the <ul> tag and add class=”nav nav-tabs”. Now we can add our tabs using the <li> tag. Remember to assign one tab with class=”active” to view it as the default active tab. Now, we need to write the content of each tab using the class=”tab-pane” within the class=” tab-content”. Note that you must assign ids to the respective tab-pane.
Adding the class=”fade” adds a fading effect when the tabs are switched.

Example: 

HTML




<!DOCTYPE html>
<html lang="en">
<head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
</head>
<body>
    <div class="container" style="color:green">
        <h1>GeeksforGeeks</h1>
    </div>
    <div class="container">
        <h4>Navigation Tabs in Bootstrap</h4>
    </div>
    <div class="container">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <div class="navbar-header">
                    <a class="navbar-brand" href="#">
                        Nav bar
                    </a>
                </div>
                <ul class="nav navbar-nav">
                    <li class="active">
                        <a href="#">Home</a>
                    </li>
                    <li><a href="#">Practice</a></li>
                    <li><a href="#">Interviews</a></li>
                    <li><a href="#">Contribute</a></li>
                </ul>
            </div>
        </nav>
    </div>
</body>
</html>


Output:

You can change the look and feel of the tabs by changing the class=”navbar-nav” to “nav-pills” or “nav-stacked” and if you want your tabs to cover the whole screen then, try adding the class=”nav-justified”
Similar to Dropdowns, we can disable any tab using class=”disabled”.

Output:

 Bootstrap DropDowns and Responsive Tabs

Note: Be careful during the use of nav-bar it will change its size depending on the screen size.



Previous Article
Next Article

Similar Reads

Bootstrap 5 Dropdowns Dark dropdowns
Bootstrap 5 Dropdowns Dark dropdowns are needed to match the navbar or site theme. Add .dropdown-menu-dark to an existing .dropdown-menu to enable darker dropdowns to match a dark navbar or custom style. No changes are necessary for the dropdowns. Prerequisites: Refer to buttons and dropdowns for customizing components for Dark dropdowns. Bootstrap
2 min read
Bootstrap 5 Dropdowns Responsive alignment
Bootstrap 5 Dropdowns Responsive alignment is used to align dropdowns by using the responsive variation classes. We need to add a breakpoint-specific alignment class to make the dropdown alignment responsive. Dropdown Responsive alignment classdropdown-menu{-*}-end: To align the dropdown right with a given breakpoint. Here * can be replaced by sm,
2 min read
Foundation CSS Responsive Accordion Tabs
Foundation CSS is a front-end framework used for responsive websites, apps, and emails for any device. It also has many front-end templates like Bootstrap, Semantic UI, and other Front-end frameworks. It is flexible, readable and it is completely customizable. Top tech giants like Adobe, Amazon, Cisco, Hp, Mozilla, Samsung, etc. are using Foundatio
6 min read
Foundation CSS Responsive Accordion Tabs Basics
Foundation CSS is a front-end framework used for responsive websites, apps, and emails for any device. It also has many front-end templates like Bootstrap, Semantic UI, and other Front-end frameworks. It is flexible, readable and it is completely customizable. Top tech giants like Adobe, Amazon, Cisco, Hp, Mozilla, Samsung, etc. are using Foundatio
8 min read
Foundation CSS Responsive Accordion Tabs Sass Reference
Foundation CSS is a front-end framework used for responsive websites, apps, and emails for any device. It also has many front-end templates like Bootstrap, Semantic UI, and other Front-end frameworks. It is flexible, readable and it is completely customizable. Top tech giants like Adobe, Amazon, Cisco, Hp, Mozilla, Samsung, etc. are using Foundatio
7 min read
Bootstrap 4 | Dropdowns
Dropdowns are one of the most important parts of an interactive website. A dropdown menu is the collection of menu items that allow users to choose a value from the list. The .dropdown class is used to design the drop-down menu. Example: C/C++ Code <!DOCTYPE html> <html lang="en"> <head> <title>Dropdowns</title
8 min read
Pills with Dropdowns in Bootstrap
Bootstrap provides various options for improving the navigation of the content. Bootstrap dropdowns are the toggleable menu for displaying a list of data, made interactive with the JavaScript plugin. We can toggle the list by clicking. Along with this, we can use bootstrap component pills with a dropdown with the bootstrap menu as pills which makes
2 min read
Bootstrap 5 Dropdowns Dropleft
Bootstrap 5 Dropdowns Dropleft is used to open the dropdown on the left-hand side of the user. Dropdown menus can be set up to the left of the elements by adding .dropstart to the parent element. Bootstrap 5 Dropdowns Dropleft Class: dropstart: This class is used to launch dropdown menus to the right of the button. Syntax: <div class="btn-group
2 min read
Bootstrap 5 Dropdowns Alignment options
In Bootstrap 5 we can use classes on the dropdown container to make it aligned as per need. We have different options to align where the dropdown menu will open like dropEnd, dropStart, dropUp, dropDown, etc. Bootstrap 5 Dropdowns Alignment options Classes: dropend: This class is used to make dropdown to the enddropdown-menu-end: For right aligned
2 min read
Bootstrap 5 Dropdowns Menu alignment
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. The .dropdown class is used to design the drop-down menu. Using Bootstrap 5 dropdown menu alignment classes dropdown menu can be aligned in any direction like the end, start, drop start,dropUp, etc Dropdown Menu Alignment option: The dropdown menu is positioned 10
2 min read
Bootstrap 5 Dropdowns Auto close behavior
Bootstrap 5 Dropdowns Auto close behavior is used to make the dropdowns close when we click outside of that dropdown or that particular button. Getting close when the user clicks outside is a necessary feature that every dropdown should have. Bootstrap 5 Dropdowns Auto close behavior Class: There is no pre-defined class to close the dropdown automa
2 min read
Bootstrap 5 Dropdowns Menu content Headers
Bootstrap 5 Dropdowns Menu content Headers are used to add a header/title to the menu in the dropdown. This can help the user to segregate drop-down options into categories. Bootstrap 5 Dropdowns Menu content Headers Class: dropdown-header: This class is used for creating a dropdown header. Syntax: <ul class="dropdown-menu"> <li><h6
2 min read
Bootstrap 5 Dropdowns Active
Bootstrap5 Dropdowns Active helps to set the state of any item in the dropdown menu as active. By default, the active item's background color will be set to blue and the text color will be set to white to make it different from the surrounding items. Dropdowns Active Class: active: This class is used with a dropdown-item to make it active. Syntax:
2 min read
Bootstrap 5 Dropdowns Directions
Bootstrap 5 Dropdowns Directions are used to change the direction in which we want the dropdown to pop up. The arrow direction is changed based on the direction set for the dropdown to appear. Bootstrap 5 Dropdowns Directions: Dropdown Dropleft: This is used to show dropdown menus left-side of the reader by using the .dropstart class.Dropdowns Drop
2 min read
Bootstrap 5 Input group Buttons with dropdowns
Bootstrap 5 Input group Buttons with dropdowns is used to display a button along with an input group. On Clicking this button, it gives a dropdown menu. Input group Buttons with dropdowns Classes: No special classes are used in Input group Buttons with dropdowns. You can customize the component using input group and dropdown classes. Syntax: <di
2 min read
Bootstrap 5 Dropdowns Menu Content Dividers
Bootstrap 5 Dropdowns Menu content Dividers Separate groups of related menu items with a divider. It is like a straight line that divides the drop-down options. Dropdowns Menu content Dividers Class: dropdown-divider: This class is used for creating a dropdown divider. Syntax: <ul class="dropdown-menu"> <li><hr class="dropdown-divide
2 min read
Bootstrap 5 Dropdowns Dropright
Bootstrap 5 Dropdowns Dropright is used to open the dropdown on the right-hand side of the user, We can one the dropdowns anywhere Bootstrap 5 Dropdowns Dropright Class: dropend: This class is used to launch dropdown menus to the right of the button. Syntax <div class="btn-group dropend"> <button type="button" class="btn dropdown-toggle" d
2 min read
Bootstrap 5 Dropdowns Usage
Bootstrap 5 dropdowns allow users to display a list of options that can be selected by clicking on a button or link. They are often used in navigation menus, form selectors, and other user interfaces. To use a dropdown in Bootstrap 5, you will need to include the Bootstrap CSS and JavaScript files in your project. Approach: To create a dropdown, yo
6 min read
React-Bootstrap Dropdowns Menu dividers
React-Bootstrap Dropdown menus with dividers are widely used in web design and application development. They help organize and categorize options within a dropdown menu, making it easier for users to find and select what they want. Dividers in these menus are used to visually separate different sections of the menu, creating a clear structure withi
2 min read
React-Bootstrap Dropdowns Sizing
React-Bootstrap Dropdowns are used to display content when users click or hover on them. React Bootstrap Dropdown sizing is set to fix the width of Dropdown so that it should be responsive for all screens. React-Bootstrap Dropdowns Sizing Used classes:large: This class is used to create dropdowns with large sizes.small: This class is used to create
2 min read
React-Bootstrap Dark dropdowns
React Bootstrap Dark Dropdowns are used for dark screen User Interfaces. In this article we are going to implement dark Dropdowns using React Bootstrap Dark Dropdown which contains attributes. React Bootstrap Dark DropDowns variant : It is used when we are implementing dark navbar.menuVariant: It is used when we are implementing dark DropDownButton
2 min read
React-Bootstrap Dropdowns Customization
React-Bootstrap Dropdowns Customization is used to make dropdown menus in React apps look and behave just the way you want. It lets you change their appearance, colors, and how they open and close, so they fit perfectly with your project's style and functionality. Custom dropdown component:You can define custom components and pass them as the "as"
2 min read
Bootstrap 5 Dropdowns Sizing
Bootstrap 5 Dropdowns Sizing is used to create dropdowns on different sizes of buttons. It normally works on any size of a button, there can be a single large button or a split small button. Bootstrap 5 Dropdowns Sizing Class: There is no pre-defined class for this you can use the Bootstrap 5 Dropdowns and Bootstrap 5 Button Sizes to customize your
2 min read
Angular ngx bootstrap Dropdowns Component
Angular ngx bootstrap is a bootstrap framework used with angular to create components with great styling and this framework is very easy to use and is used to make responsive websites. In this article, we will see how to use Dropdowns in angular ngx bootstrap. Installation syntax: npm install ngx-bootstrap --save Approach: First, install the angula
2 min read
Bootstrap 5 Dropdowns Menu Content Text
Bootstrap 5 Dropdowns Menu Content text is placed in the freeform in the dropdown menu. There is no special margin to place the text within a dropdown menu. Pre-requisite: Bootstrap 5 Dropdown, Bootstrap 5 Spacing & Bootstrap 5 Buttons. Bootstrap 5 Dropdowns Menu content Text classes: No specific class is used for Dropdowns Menu content Text. T
2 min read
React-Bootstrap Dropdowns Drop directions
The React bootstrap provides us with the bootstrap components out of the box compared to normal React, It comes with the pre-applied CSS and the themes and properties of the bootstrap component can be modified by changing the properties. The Dropdown component is used for showing dropdowns in React Bootstrap. The dropdowns contain a list of hyperli
3 min read
Bootstrap 5 Dropdowns Single Button
Bootstrap 5 Dropdowns Single button is used to turn a button into a dropdown toggle with some basic markup. A dropdown button lets the user select from a number of items. Bootstrap 5 Dropdowns Single Button class:dropdown-toggle: This class is used to make the button drop down.Syntax:<div class="dropdown"> <button class="btn dropdown-toggl
2 min read
Bootstrap 5 Dropdowns Dropup
Bootstrap 5 Dropdowns Dropup is used to show dropdown menus above the parent elements by using the .dropup class. Bootstrap 5 Dropdowns Dropup Class: dropup: To launch dropdown menus above elements.Syntax: <div class="btn-group dropup"> ...</div>Example 1: This example describes the basic usage of the Dropdowns Dropup in Bootstrap 5 [GF
2 min read
Bootstrap 5 Dropdowns Menu items
Bootstrap 5 Dropdowns Menu items are a list of options on a website that appears only when a user interacts with the menu, like by clicking on it or hovering over it.  Bootstrap 5  Dropdowns Menu items: Bootstrap 5 Dropdowns Menu items Active: It helps to set the state of any item in the dropdown menu as activeBootstrap 5 Dropdowns Menu items Disab
2 min read
Bootstrap 5 Dropdowns Disabled
Bootstrap 5 Dropdowns Disabled is used to disable some text items in the dropdown. A disabled drop-down list is unusable and un-clickable. Bootstrap 5 Dropdowns Disabled classes: There is no specific class for the Bootstrap 5 Dropdowns disabled feature, we need to add a combination of Bootstrap5 Dropdown classes. Bootstrap 5 Dropdowns Disabled Attr
3 min read
three90RightbarBannerImg