Dropdowns

Bootstrap dropdowns

Note: This documentation is for an older version of Bootstrap (v.4). A newer version is available for Bootstrap 5. We recommend migrating to the latest version of our product - Material Design for Bootstrap 5.
Go to docs v.5

Toggle contextual overlays for displaying lists of links and more with the Bootstrap dropdown plugin.


Overview

Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They’re made interactive with the included Bootstrap dropdown JavaScript plugin. They’re toggled by clicking, not by hovering; this is an intentional design decision.

In case of more complicated navigations systems dropdowns are the essential elements providing you with the possibility of placing all the most relevant links onto our navigation bar (or other component acting in navigation role - such as SideNav)

Aside from being not only highly functional, MDB dropdowns are also extraordinary visually attractive. It gives them the characteristic Material Design effects, like shadows, living colors or a charming waves effect after opening a link.

They’re toggled by clicking, not by hovering; as this is an intentional design decision. Why?

Because MDB is "mobile first" framework so, we avoid mixing functional elements and interaction by hovering because it decreases User Experience of users of mobile devices.

Google Material Design guidelines recommend the same approach.


Accessibility

The WAI ARIA standard defines an actual role="menu" widget, but this is specific to application-like menus which trigger actions or functions. ARIA menus may only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus.

Bootstrap’s dropdowns, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures. For instance, it is possible to create dropdowns that contain additional inputs and form controls, such as search fields or login forms. For this reason, Bootstrap does not expect (nor automatically add) any of the role and aria- attributes required for true ARIA menus. Authors will have to include these more specific attributes themselves.

However, Bootstrap does add built-in support for most standard keyboard menu interactions, such as the ability to move through individual .dropdown-item elements using the cursor keys and close the menu with the ESC key.


Examples

You can wrap the dropdown’s toggle (your button or link) and the dropdown menu within <button> elements to better fit your potential needs.

Single button

Any single .btn can be turned into a dropdown toggle with some markup changes. Here’s how you can put them to work with either button element:


Default dropdown

Default styling for the Bootstrap Dropdown component

        
            

            <!-- Basic dropdown -->
            <button class="btn btn-primary dropdown-toggle mr-4" type="button" data-toggle="dropdown"
              aria-haspopup="true" aria-expanded="false">Basic dropdown</button>

            <div class="dropdown-menu">
              <a class="dropdown-item" href="#">Action</a>
              <a class="dropdown-item" href="#">Another action</a>
              <a class="dropdown-item" href="#">Something else here</a>
              <div class="dropdown-divider"></div>
              <a class="dropdown-item" href="#">Separated link</a>
            </div>
            <!-- Basic dropdown -->

          
        
    

Material dropdown MDB Pro component

The Material Design styling for Bootstrap Dropdown component

        
            

            <!--Dropdown primary-->
            <div class="dropdown">

              <!--Trigger-->
              <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown"
                aria-haspopup="true" aria-expanded="false">Material dropdown</button>

              <!--Menu-->
              <div class="dropdown-menu dropdown-primary">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <a class="dropdown-item" href="#">Something else here</a>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </div>
            <!--/Dropdown primary-->

          
        
    

Default dropdown with a element

Default styling for the Bootstrap Dropdown component with a element

        
            

            <!-- Basic dropdown -->
            <a class="btn btn-primary dropdown-toggle mr-4" type="button" data-toggle="dropdown" aria-haspopup="true"
              aria-expanded="false">Basic dropdown</a>

            <div class="dropdown-menu">
              <a class="dropdown-item" href="#">Action</a>
              <a class="dropdown-item" href="#">Another action</a>
              <a class="dropdown-item" href="#">Something else here</a>
              <div class="dropdown-divider"></div>
              <a class="dropdown-item" href="#">Separated link</a>
            </div>
            <!-- Basic dropdown -->

          
        
    

Material dropdown with a element MDB Pro component

The Material Design styling for Bootstrap Dropdown component with a element

        
            

            <!--Dropdown primary-->
            <div class="dropdown">

              <!--Trigger-->
              <a class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown"
                aria-haspopup="true" aria-expanded="false">Material dropdown</a>


              <!--Menu-->
              <div class="dropdown-menu dropdown-primary">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <a class="dropdown-item" href="#">Something else here</a>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </div>
            <!--/Dropdown primary-->

          
        
    

Split button

Similarly, you can create split button dropdowns with virtually the same markup as single button dropdowns, but with the addition of the class .dropdown-toggle-split for proper spacing around the dropdown caret.

We use this extra class to reduce the horizontal padding on either side of the caret by 25% and remove the margin-left that’s added for regular button dropdowns. Those extra changes keep the caret centered in the split button and provide a more appropriately sized hit area next to the main button.

        
            

          <!-- Split button -->
          <div class="btn-group">
            <button type="button" class="btn btn-danger">Danger</button>
            <button type="button" class="btn btn-danger dropdown-toggle px-3" data-toggle="dropdown" aria-haspopup="true"
              aria-expanded="false">
              <span class="sr-only">Toggle Dropdown</span>
            </button>
            <div class="dropdown-menu">
              <a class="dropdown-item" href="#">Action</a>
              <a class="dropdown-item" href="#">Another action</a>
              <a class="dropdown-item" href="#">Something else here</a>
              <div class="dropdown-divider"></div>
              <a class="dropdown-item" href="#">Separated link</a>
            </div>
          </div>

        
        
    

Material dropdowns MDB Pro component

        
            
          <!--Dropdown primary-->
          <div class="dropdown">

            <!--Trigger-->
            <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown"
              aria-haspopup="true" aria-expanded="false">Dropdown primary</button>


            <!--Menu-->
            <div class="dropdown-menu dropdown-primary">
              <a class="dropdown-item" href="#">Action</a>
              <a class="dropdown-item" href="#">Another action</a>
              <a class="dropdown-item" href="#">Something else here</a>
              <a class="dropdown-item" href="#">Something else here</a>
            </div>
          </div>
          <!--/Dropdown primary-->
        
        
    

It's very easy to use our dropdown search.

All you have to do is add #ID to the menu wrapper and initiate a function with this JavaScript code.

        
            

        $('#your-custom-id').mdbDropSearch();

      
        
    
        
            

        <!--Dropdown primary-->
        <div class="dropdown">
          <!--Trigger-->
          <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1-1"
            data-toggle="dropdown">Bootstrap
            search</button>

          <!--Menu-->
          <div class="dropdown-menu dropdown-primary" id="your-custom-id">
            <input class="form-control" type="text" placeholder="Search" aria-label="Search">
            <a class="dropdown-item mdb-dropdownLink-1" href="/">MDB</a>
            <a class="dropdown-item mdb-dropdownLink-1" href="/docs/b4/react/">MDB react</a>
            <a class="dropdown-item mdb-dropdownLink-1" href="/docs/b4/angular/">MDB angular</a>
            <a class="dropdown-item mdb-dropdownLink-1" href="/docs/b4/vue/">MDB vue</a>
            <a class="dropdown-item mdb-dropdownLink-1" href="https://brandflow.net/">BrandFlow</a>
            <a class="dropdown-item mdb-dropdownLink-1" href="/education/bootstrap/">MDB
              Rocks</a>
          </div>
        </div>
        <!--/Dropdown primary-->

      
        
    

You can also use material design to style your dropdown with search.

        
            

        $('#your-custom-id-material').mdbDropSearch();

      
        
    
        
            

        <!--Dropdown danger-->
        <div class="dropdown">
          <!--Trigger-->
          <button class="btn btn-danger dropdown-toggle" type="button" id="dropdownMenu2-1"
            data-toggle="dropdown">Material
            search</button>

          <!--Menu-->
          <div class="dropdown-menu dropdown-danger" id="your-custom-id-material">
            <!-- Search form -->
            <div class="md-form">
              <input class="form-control" type="text" placeholder="Search" aria-label="Search">
            </div>
            <a class="dropdown-item mdb-dropdownLink-2" href="/">MDB</a>
            <a class="dropdown-item mdb-dropdownLink-2" href="/docs/b4/react/">MDB react</a>
            <a class="dropdown-item mdb-dropdownLink-2" href="/docs/b4/angular/">MDB angular</a>
            <a class="dropdown-item mdb-dropdownLink-2" href="/docs/b4/vue/">MDB vue</a>
            <a class="dropdown-item mdb-dropdownLink-2" href="https://brandflow.net/">BrandFlow</a>
            <a class="dropdown-item mdb-dropdownLink-2" href="/education/bootstrap/">MDB
              Rocks</a>
          </div>
        </div>
        <!--/Dropdown danger-->

      
        
    

Additional to our dropdown with search you can also add a button to your dropdown filed.

        
            

        $('#your-custom-id-button').mdbDropSearch();

      
        
    
        
            

        <!--Dropdown warning-->
        <div class="dropdown">
          <!--Trigger-->
          <button class="btn btn-warning dropdown-toggle" type="button" id="dropdownMenu2-2" data-toggle="dropdown"
            aria-haspopup="true" aria-expanded="false">With button</button>

          <!--Menu-->
          <div class="dropdown-menu dropdown-warning" id="your-custom-id-button">
            <!-- Search form -->
            <div class="md-form text-center">
              <input class="form-control" type="text" placeholder="Search" aria-label="Search">
              <button class="btn btn-mdb-color btn-rounded btn-sm my-0" type="button">Search</button>
            </div>
            <a class="dropdown-item mdb-dropdownLink" href="/">MDB</a>
            <a class="dropdown-item mdb-dropdownLink" href="/docs/b4/react/">MDB react</a>
            <a class="dropdown-item mdb-dropdownLink" href="/docs/b4/angular/">MDB angular</a>
            <a class="dropdown-item mdb-dropdownLink" href="/docs/b4/vue/">MDB vue</a>
            <a class="dropdown-item mdb-dropdownLink" href="https://brandflow.net/">BrandFlow</a>
            <a class="dropdown-item mdb-dropdownLink" href="/education/bootstrap/">MDB
              Rocks</a>
          </div>
        </div>
        <!--/Dropdown warning-->

      
        
    

Sizing

Button dropdowns work with buttons of all sizes

        
            

        <!-- Large button group -->
        <div class="btn-group">
          <button class="btn btn-danger btn-lg dropdown-toggle" type="button" data-toggle="dropdown"
            aria-haspopup="true" aria-expanded="false">
            Large button
          </button>
          <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
          </div>
        </div>
        <!-- Large split button group -->
        <div class="btn-group">
          <button type="button" class="btn btn-danger btn-lg">Large split button</button>
          <button type="button" class="btn btn-danger btn-lg dropdown-toggle px-3" data-toggle="dropdown"
            aria-haspopup="true" aria-expanded="false">
            <span class="sr-only">Toggle Dropdown</span>
          </button>
          <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
          </div>

        </div>
        <!-- Small split button group -->
        <div class="btn-group">
          <button type="button" class="btn btn-danger btn-sm">Small split button</button>
          <button type="button" class="btn btn-danger btn-sm dropdown-toggle px-3" data-toggle="dropdown"
            aria-haspopup="true" aria-expanded="false">
            <span class="sr-only">Toggle Dropdown</span>
          </button>
          <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
          </div>
        </div>

        <!-- Small button group -->
        <div class="btn-group">
          <button class="btn btn-danger btn-sm dropdown-toggle" type="button" data-toggle="dropdown"
            aria-haspopup="true" aria-expanded="false">
            Small button
          </button>
          <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
          </div>
        </div>

      
        
    

Dropup variation

Trigger dropdown menus above elements by adding the class .dropup to the parent.

        
            

        <div class="btn-group dropup">
          <button type="button" class="btn btn-primary">Dropup</button>
          <button type="button" class="btn btn-primary dropdown-toggle px-3" data-toggle="dropdown" aria-haspopup="true"
            aria-expanded="false">
            <span class="sr-only">Toggle Dropdown</span>
          </button>
          <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
          </div>
        </div>

      
        
    

Dropright variation

Trigger dropdown menus at the right of the elements by adding the class .dropright to the parent element.

        
            

        <div class="btn-group dropright">
          <button type="button" class="btn btn-primary">Dropright</button>
          <button type="button" class="btn btn-primary dropdown-toggle px-3" data-toggle="dropdown" aria-haspopup="true"
            aria-expanded="false">
            <span class="sr-only">Toggle Dropdown</span>
          </button>
          <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
          </div>
        </div>

      
        
    

Dropleft variation

Trigger dropdown menus at the right of the elements by adding the class .dropleft to the parent element.

        
            

        <div class="btn-group dropleft">
          <button type="button" class="btn btn-primary dropdown-toggle px-3" data-toggle="dropdown" aria-haspopup="true"
            aria-expanded="false">
            <span class="sr-only">Toggle Dropdown</span>
          </button>
          <div class="dropdown-menu">
            <a class="dropdown-item" href="#">Action</a>
            <a class="dropdown-item" href="#">Another action</a>
            <a class="dropdown-item" href="#">Something else here</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Separated link</a>
          </div>
          <button type="button" class="btn btn-primary">Dropleft</button>
        </div>

      
        
    






Active menu items

Add the class .active to items in the dropdown to style them as active.

        
            

        <div class="dropdown">
          <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu6" data-toggle="dropdown"
            aria-haspopup="true" aria-expanded="false">
            Dropdown
          </button>
          <div class="dropdown-menu" aria-labelledby="dropdownMenu6">
            <a class="dropdown-item" href="#">Regular link</a>
            <a class="dropdown-item active" href="#">Active link</a>
            <a class="dropdown-item" href="#">Another link</a>
          </div>
        </div>

      
        
    

Disabled menu items

Add the class .disabled to items in the dropdown to style them as disabled.

        
            

        <div class="dropdown">
          <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu5" data-toggle="dropdown"
            aria-haspopup="true" aria-expanded="false">
            Dropdown
          </button>
          <div class="dropdown-menu" aria-labelledby="dropdownMenu5">
            <a class="dropdown-item" href="#">Regular link</a>
            <a class="dropdown-item disabled" href="#">Disabled link</a>
            <a class="dropdown-item" href="#">Another link</a>
          </div>
        </div>

      
        
    

Multi-level dropdown

        
            
        
        <ul style="list-style-type:none">
          <li>
            <button href="#" type="button" id="dropdown" data-toggle="dropdown"
              class=" btn btn-primary dropdown-toggle multi-level-dropdown" aria-haspopup="true"
              aria-expanded="false">Click me</button>
            <ul style="list-style-type:none" class="dropdown-menu mt-2 rounded-0 white border-0 z-depth-1">
              <li class="dropdown-item dropdown-submenu p-0">
                <a href="#" data-toggle="dropdown" class="dropdown-toggle dropdown-item w-100">Click Me! </a>
                <ul class="dropdown-menu  rounded-0 white border-0 z-depth-1">
                  <li class="dropdown-item p-0">
                    <a href="#" class="dropdown-item w-100">Hey</a>
                  </li>
                  <li class="dropdown-item p-0">
                    <a href="#" class="dropdown-item w-100">Hi</a>
                  </li>
                  <li class="dropdown-item p-0">
                    <a href="#" class="dropdown-item w-100">Hello</a>
                  </li>
                </ul>
              </li>
              <li class="dropdown-item dropdown-submenu p-0">
                <a href="#" data-toggle="dropdown" class="dropdown-toggle dropdown-item w-100">Click Me Too! </a>
                <ul class="dropdown-menu mr-2 rounded-0  white border-0 z-depth-1 r-100">
                  <li class="dropdown-item p-0">
                    <a href="#" class="dropdown-item w-100">How</a>
                  </li>
                  <li class="dropdown-item p-0">
                    <a href="#" class="dropdown-item w-100">are</a>
                  </li>
                  <li class="dropdown-item dropdown-submenu p-0">
                    <a href="#" data-toggle="dropdown" class="dropdown-toggle dropdown-item w-100">Click Me Too! </a>
                    <ul style="list-style-type:none"
                      class="dropdown-menu mr-2 rounded-0 white border-0 z-depth-1 r-100 ">
                      <li class="dropdown-item p-0">
                        <a href="#" class="dropdown-item w-100">How</a>
                      </li>
                      <li class="dropdown-item p-0">
                        <a href="#" class="dropdown-item w-100">are</a>
                      </li>
                    </ul>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
        </ul>

      
        
    


Usage

Using either data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .show class on the parent list item. The data-toggle="dropdown" attribute is relied upon to close dropdown menus at an application level, so it’s a good idea to always use it.

On touch-enabled devices, opening a dropdown adds empty ($.noop) mouseover handlers to the immediate children of the <body> element. This admittedly ugly hack is necessary to work around a quirk in iOS’ event delegation , which would otherwise prevent a tap anywhere outside of the dropdown from triggering the code that closes the dropdown. Once the dropdown is closed, these additional empty mouseover handlers are removed.

Via data attributes

Add data-toggle="dropdown" to a link or button to toggle a dropdown.

        
            
          <div class="dropdown">
            <button id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Dropdown trigger
            </button>
            <div class="dropdown-menu" aria-labelledby="dLabel">
              ...
            </div>
          </div>
        
        
    

Via JavaScript

Call the dropdowns via JavaScript, though note that

data-toggle="dropdown" is still required

Regardless of whether you call your dropdown via JavaScript or instead use the data-api, data-toggle="dropdown" is always required to be present on the dropdown’s trigger element.

        
            
          $('.dropdown-toggle').dropdown()
        
        
    

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-offset="".

Name Type Default Description
offset number | string | function 0 Offset of the dropdown relative to its target. For more information refer to Popper.js's offset docs.
flip boolean true Allow Dropdown to flip in case of an overlapping on the reference element. For more information refer to Popper.js's flip docs.
boundary string | element 'scrollParent' Overflow constraint boundary of the dropdown menu. Accepts the values of 'viewport', 'window', 'scrollParent', or an HTMLElement reference (JavaScript only). For more information refer to Popper.js's preventOverflow docs.

Note when boundary is set to any value other than 'scrollParent', the style position: static is applied to the .dropdown container.

Methods

Method Description
$().dropdown('toggle') Toggles the dropdown menu of a given navbar or tabbed navigation.
$().dropdown('update') Updates the position of an element’s dropdown.
$().dropdown('dispose') Destroys an element’s dropdown.

Events

All dropdown events are fired at the .dropdown-menu’s parent element and have a relatedTarget property, whose value is the toggling anchor element.

Event Description
show.bs.dropdown This event fires immediately when the show instance method is called.
shown.bs.dropdown This event is fired when the dropdown has been made visible to the user (will wait for CSS transitions, to complete).
hide.bs.dropdown This event is fired immediately when the hide instance method has been called.
hidden.bs.dropdown This event is fired when the dropdown has finished being hidden from the user (will wait for CSS transitions, to complete).
        
            
          $('#myDropdown').on('show.bs.dropdown', function () {
          // do something…
          })