Dropdowns
Angular Bootstrap 5 Dropdown component
Toggle contextual overlays for displaying lists of links and more with the MDB dropdown plugin.
Note: Read the API tab to find all available options and advanced customization
Basic examples
Wrap the dropdown’s toggle (your button or link) and the dropdown menu within
.dropdown
and mdbDropdown
, or another element that declares
position: relative;
. Dropdowns can be triggered from <a>
or
<button>
within mdbDropdownTrigger
elements to better fit
your potential needs. The examples shown here use semantic <ul>
elements
where appropriate, but custom markup is supported.
Colors
You can do this with any button variant:
Sizing
Button dropdowns work with buttons of all sizes, including default and split dropdown buttons.
Directions
Dropup
Trigger dropdown menus above elements by adding .dropup
to the parent
element.
Dropright
Trigger dropdown menus at the right of the elements by adding
.dropend
to the parent element.
Dropleft
Trigger dropdown menus at the left of the elements by adding
.dropstart
to the parent element.
Dynamic direction
You can also set dropdown's direction with the help of positionClass
input. It handles dynamic changes and can be useful to change dropdown's direction on some
action for example changing view from landscape to portrait.
Remove animation
To remove the fade animation on click, add
[animation]="false"
attribute to the dropdown.
Dropdown options
Use offset
to change the location of the dropdown.
Dark variant
Add .dropdown-menu-dark
onto an existing .dropdown-menu
to match a
dark navbar.
Dropdowns - API
Import
Inputs
MdbDropdownDirective
Name | Type | Default | Description |
---|---|---|---|
animation |
boolean | true |
Defines whether animation is enabled |
closeOnEsc |
boolean | true |
Defines whether dropdown closes on ESC |
closeOnItemClick |
boolean | true |
Defines whether dropdown closes on item click |
closeOnOutsideClick |
boolean | true |
Defines whether dropdown closes on outside click |
offset |
number | 0 |
Offset of the dropdown relative to its target |
positionClass |
MdbDropdownPositionClass | - |
Defines dropdown's direction |
withPush |
boolean | false |
Defines whether dropdown can be pushed on-screen if none of the provided positions fit |
MdbDropdownMenuDirective
Name | Type | Default | Description |
---|---|---|---|
menuPositionClass |
string | - |
Defines dropdown's menu alignment |
Outputs
Name | Description | Example |
---|---|---|
dropdownShow
|
EventEmitter<MdbDropdownDirective> | Fires immediately when the show instance method is called. |
dropdownShown
|
EventEmitter<MdbDropdownDirective> | Fired when the dropdown has been made visible to the user and CSS transitions have completed. |
dropdownHide
|
EventEmitter<MdbDropdownDirective> | Fires immediately when the hide instance method has been called. |
dropdownHidden
|
EventEmitter<MdbDropdownDirective> | Fired when the dropdown has finished being hidden from the user and CSS transitions have completed. |
Methods
Name | Description | Example |
---|---|---|
hide |
Hides the dropdown menu of a given navbar or tabbed navigation. |
dropdown.hide()
|
show |
Shows the dropdown menu of a given navbar or tabbed navigation. |
dropdown.show()
|
toggle |
Toggles the dropdown menu of a given navbar or tabbed navigation. |
dropdown.toggle()
|
CSS variables
As part of MDB’s evolving CSS variables approach, dropdown now uses local CSS variables on
.dropdown-menu
, .dropdown-item
and .dropdown-divider
for enhanced real-time customization. Values for the CSS variables
are set via Sass, so Sass customization is still supported, too.