Bootstrap 4 Dropdowns |
Here is an example of a bootstrap 4 dropdown,
The .dropdown class represents the dropdown menu. The .dropdown-toggle class is used to show or hide the menu items based on data-toggle="dropdown" attribute of button click events.
Include the .dropdown-menu to a <div> element to create the dropdown menu and include .dropdown-item class to each <a> (or button) elements to create the items list.
Dropdown with Headers
Include the .dropdown-header class inside the dropdown menu to create the fancy dropdown headers. Let's look into the below example,Dropdown with Dividers
The dividers are used to separate groups of related menu items.Dropdown with Active & Disabled menu items
See the Pen Bootstrap 4 Dropdown with Active & Disabled menu items by Prime Study Hub (@PrimeStudyHub) on CodePen.
- For Active dropdown items, Add .active class to your .dropdown-item class. (class="dropdown-item active")
- For Disabled dropdown items, Add .disabled class to your .dropdown-item class. (class="dropdown-item disabled")
Dropdown Positions
You can position your dropdown by using .dropright class for the right dropdown menu or .dropleft class for the left dropdown menu.
Comments