Use native Bootstrap grid content in a dropdown menu.
About the Plugin
We extended the Bootstrap dropdowns plugin to provide dropdowns with the flexibility of Bootstrap's grid. Using familiar markup and data attributes, you can nest any type of content in a dropdown, including other dropdowns!
This allows for multi-level dropdown menus and so-called "Mega Menus".
Dropdowns may be triggered on click or hover, and automatically position themselves to fit in the window.
Initializing
The demo pages already include the following code. These steps are only necessary if you are building a page from scratch. Remove these references if you are not using this plugin to improve page load times.
Load the plugin code in index.js
Declare the following import statement in js/mrare/index.js. This ensures that the initializer code is included in the theme.js bundle.
import mrDropdownGrid from'./dropdown-grid';
Export the necessary object from theme.js
Edit the export object in js/mrare/index.js to include the following:
export{
mrDropdownGrid,};
Basic Usage
Grid Dropdowns follow the same structure as a Bootstrap dropdown with the following differences:
Use data-toggle="dropdown-grid" instead of data-toggle="dropdown".
Immediate child of div.dropdown-menu may be div.container or div.row
Immediate child of div.dropdown-menu must have attribute data-dropdown-content
In this example, the dropdown is full-width, so div.dropdown-menu contains a div.container > div.row > div.col structure.
In addition to triggering on click, Grid Dropdowns may also be triggered on hover. See below table for how to enable hover option.
Data attribute
Default
Usage
data-dropdown-grid-hover
false
Apply data-dropdown-grid-hover="true" on the page <body> to enable hover for all Grid Dropdowns on the page
data-hover
false
Apply data-hover to individual [data-toggle="dropdown-grid"] elements with true or false to override the page default.
Nested Dropdowns
Grid Dropdowns may be nested inside Grid Dropdowns to create multi-level dropdown menus.
In this case, the class row is added to div.dropdown-menu and its immediate child is div.col-auto. This is necessary to display the dropdown menus at their natural width.
Any content may be nested inside Grid Dropdowns allowing maximum flexibility and mobile responsiveness.
In this case, the class row is added to div.dropdown-menu and its immediate child is div.col-auto. This is necessary to display the dropdown menus at their natural width.