Angular Bootstrap Dropdowns

Angular dropdowns - Bootstrap 4 & Material Design

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 Angular Bootstrap dropdown.


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 possibility of placing all the most relevant links in our navigation bar (or other component acting as navigation - such as SideNav)

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

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

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 can 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 button 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

        
            
                <div class="btn-group" mdbDropdown>
                  <button 
                    mdbDropdownToggle
                    type="button"
                    mdbBtn
                    color="primary"
                    class="dropdown-toggle waves-light"
                    mdbWavesEffect
                  >
                    Basic dropdown
                  </button>
                
                  <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>
                    <div class="divider dropdown-divider"></div>
                    <a class="dropdown-item" href="#">Separated link</a>
                  </div>
                </div>
              
        
    

Material dropdown MDB Pro component

The Material Design styling for Angular Bootstrap Dropdown component

        
            
                <div class="dropdown" mdbDropdown>

                  <button
                    mdbDropdownToggle
                    mdbBtn
                    color="primary"
                    class="dropdown-toggle waves-light"
                    type="button"
                    mdbWavesEffect
                  >
                    Dropdown primary
                  </button>
                
                  <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>
              
        
    

Default dropdown with a element

Default styling for the Bootstrap Dropdown component with a element

        
            
                <div class="btn-group" mdbDropdown>
                  <a 
                    mdbDropdownToggle
                    type="button"
                    mdbBtn
                    color="primary"
                    class="dropdown-toggle waves-light"
                    mdbWavesEffect
                  >
                    Basic dropdown
                  </a>
                
                  <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>
                    <div class="divider dropdown-divider"></div>
                    <a class="dropdown-item" href="#">Separated link</a>
                  </div>
                </div>
              
        
    

Material dropdown with a element MDB Pro component

The Material Design styling for Bootstrap Dropdown component with a element

        
            
                <div class="dropdown" mdbDropdown>

                  <a 
                    mdbDropdownToggle
                    mdbBtn
                    color="primary"
                    class="dropdown-toggle waves-light"
                    type="button"
                    mdbWavesEffect
                  >
                    Dropdown primary
                  </a>
                
                  <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>
              
        
    

Split button

Similarly, create split button dropdowns with virtually the same markup as single button dropdowns, but with the addition of .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.

        
            
          <div class="btn-group" mdbDropdown>
            <button type="button" mdbBtn color="danger" class="waves-light" mdbWavesEffect>Action</button>
            <button 
              type="button"
              mdbDropdownToggle
              mdbBtn
              color="danger"
              class="dropdown-toggle dropdown-toggle-split px-3 waves-light"
              mdbWavesEffect
            ></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

        
            
          <div class="dropdown" mdbDropdown>
            <button mdbDropdownToggle mdbBtn color="primary" class="dropdown-toggle waves-light" type="button" mdbWavesEffect>
              Dropdown primary
            </button>

            <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>
        
        
    

Sizing

Button dropdowns work with buttons of all sizes

        
            
          <div class="btn-group" mdbDropdown>
            <button mdbDropdownToggle mdbBtn color="danger" size="lg" class="dropdown-toggle waves-light" type="button" mdbWavesEffect>
              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>

          <div class="btn-group" mdbDropdown>
            <button mdbDropdownToggle mdbBtn color="danger" size="sm" class="dropdown-toggle waves-light" type="button" mdbWavesEffect>
              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 [dropup]="true" to the parent.

        
            
          <div class="btn-group" mdbDropdown [dropup]="true">
            <button type="button" mdbBtn color="primary" class="waves-light" mdbWavesEffect>Dropup</button>
            <button 
              type="button"
              mdbBtn
              color="primary"
              mdbDropdownToggle
              class="dropdown-toggle dropdown-toggle-split px-3 waves-light"
              mdbWavesEffect
            ></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>
        
        
    





Active menu items

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

        
            
          <div class="dropdown" mdbDropdown>
            <button mdbDropdownToggle type="button" mdbBtn color="primary" class="dropdown-toggle waves-light" mdbWavesEffect>
              Dropdown
            </button>

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

Disabled menu items

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

        
            
          <div class="dropdown" mdbDropdown>
            <button mdbDropdownToggle type="button" mdbBtn color="primary" class="dropdown-toggle waves-light" mdbWavesEffect>
              Dropdown
            </button>

            <div class="dropdown-menu">
              <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>
        
        
    

Various dropdown elements

Use dropdown as various elements like badge, icon, avatar.

        
            
          <div class="row">
            <div class="col-md-6 mx-auto">
              <h4 class="text-center">Various dropdown elements</h4>
            </div>
            <div class="col-md-12 mx-auto mb-5 d-flex justify-content-center align-items-center flex-wrap">
              <div class="btn-group mx-4" mdbDropdown>
                <mdb-icon fas icon="user" classInside="dropdown-toggle" mdbDropdownToggle class="waves-effect" mdbWavesEffect></mdb-icon>
                <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>
                  <div class="divider dropdown-divider"></div>
                  <a class="dropdown-item" href="#">Separated link</a>
                </div>
              </div>
        
              <div class="btn-group" mdbDropdown>
                <a mdbDropdownToggle mdbWavesEffect type="button" class="dropdown-toggle waves-light" mdbWavesEffect style="height: auto; width: 30px">
                  <img src="https://mdbootstrap.com/img/Photos/Avatars/avatar-2.webp" alt="" class="img-fluid rounded-circle z-depth-0">
                </a>
                <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>
                  <div class="divider dropdown-divider"></div>
                  <a class="dropdown-item" href="#">Separated link</a>
                </div>
              </div>
        
              <div class="btn-group mx-4" mdbDropdown>
                <mdb-badge color="red" mdbDropdownToggle classInside="dropdown-toggle" class="waves-effect" mdbWavesEffect>
                  New
                </mdb-badge>
                <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>
                  <div class="divider dropdown-divider"></div>
                  <a class="dropdown-item" href="#">Separated link</a>
                </div>
              </div>
            </div>
          </div>
        
        
    

Angular Dropdown - API

In this section you will find informations about dropdown and its required modules and available inputs, outputs, methods and events.


Modules used

In order to speed up your application, you can choose to import only the modules you actually need, instead of importing the entire MDB Angular library. Remember that importing the entire library, and immediately afterwards a specific module, is bad practice, and can cause application errors.

        
            
          import { ButtonsModule, WavesModule, DropdownModule.forRoot() } from 'ng-uikit-pro-standard'
        
        
    
        
            
          import { ButtonsModule, WavesModule, DropdownModule.forRoot() } from 'angular-bootstrap-md'
        
        
    

Inputs

BsDropdownDirective
Name Type Default Description Example
autoClose boolean false Indicates that dropdown will be closed on item or document click, and after pressing ESC. autoClose="true"
dropup boolean false This attribute indicates that the dropdown should be opened upwards. dropup="true"
dropupDefault boolean false Gives the default dropup styles dropupDefault="true"
dynamicPosition boolean false Opens the component automatically at the top when there is not enough space underneath dynamicPosition="true"
isDisabled boolean false Disables dropdown toggle and hides dropdown menu if opened isDisabled="true"
isOpen boolean false Returns whether or not the popover is currently being shown isOpen="true"
placement string ' ' Placement of a popover. Accepts: "top", "bottom", "left", "right". Also .dropdown-menu-right is needed for .dropdown-menu div placement="right"
triggers string ' ' Specifies events that should trigger. Supports a space separated list of event names triggers="mousedown click"

Outputs

Name Type Description Example
isOpenChange EventEmitter<any> Emits an event when isOpen change (isOpenChange)="isOpenChange()"
hidden EventEmitter<any> Emits an event when the popover is hidden (hidden)="onHidden()"
shown EventEmitter<any> Emits an event when the popover is shown (shown)="onShown()"

Methods

To your mdbDropdown element add #dropdown='bs-dropdown'. And to the trigger add below mentioned options.

Name Description Example
show Opens an element’s popover. This is considered a “manual” triggering of the popover (event)="name.show()"
hide Closes an element’s popover. This is considered a “manual” triggering of the popover (event)="name.hide()"
toggle Toggles an element’s popover. This is considered a “manual” triggering of the popover (event)="name.toggle(value: boolean)()"