Skip to content

Bootstrap Mega Menu Dropdown

Full-width Bootstrap 5 mega menu with icon feature links, link columns and a gradient promo block, keyboard friendly and stacked on mobile.

Also known as: mega menu navbar, wide dropdown menu, multi column dropdown navigation, full width mega menu

Bootstrap Mega Menu Dropdown live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A full-width Bootstrap 5 mega menu: a navbar dropdown that opens into a wide panel with icon feature links, two plain link columns and a gradient promo block. It fits SaaS marketing sites, online stores and any header with more links than a normal dropdown can hold.

How it works

The header .mgm-root contains a standard navbar navbar-expand-lg with a brand, a collapse toggler and the #mgm-collapse area. The Products item is a li.dropdown.mgm-static whose button.mgm-toggle uses data-bs-toggle="dropdown" and data-bs-auto-close="outside", so clicks inside the panel do not close it, while clicks elsewhere and the Escape key do.

The .dropdown-menu.mgm-panel holds a Bootstrap container with a row. On screens from 992px the CSS gives .mgm-static position: static, so the absolutely positioned panel is placed against the navbar and stretches from edge to edge with left: 0 and right: 0. The columns are a Platform list of .mgm-feature links with .mgm-icon tiles, Solutions and Resources lists of .mgm-link items and the .mgm-promo card with a call-to-action. Below 992px the panel sits inside the collapsed navbar and the columns stack.

All links carry Bootstrap's dropdown-item class, so the Dropdown plugin's arrow-key navigation works across the whole panel. The script creates the dropdown with bootstrap.Dropdown.getOrCreateInstance(), opens it on load when the root has data-mgm-open-on-load and the screen is wide, and closes it with hide() when the window shrinks to the mobile layout. A .mgm-hero block below the navbar stands in for page content.

Customization

  • --mgm-accent on .mgm-root in style.css: changes the hover color, icon tiles, focus outlines and logo.
  • --mgm-bg and --mgm-panel-bg: set the navbar background and the background of the open panel.
  • --mgm-radius: rounds the bottom corners of the panel more or less.
  • Remove data-mgm-open-on-load from .mgm-root so the menu starts closed; it is only there to show the panel in the preview.
  • The linear-gradient in .mgm-promo: replace it with your brand colors or an image for the promo block.
  • Change the column classes (col-lg-4, col-lg-2) to rebalance the panel, for example four equal col-lg-3 columns.
  • Change data-bs-auto-close="outside" on .mgm-toggle to true to close the panel after any click inside it.

Use cases

  • SaaS marketing sites: a Products menu opens a wide panel with icon feature links and a promo block
  • Online stores: several link columns fit more categories than a normal dropdown can hold
  • Corporate websites: a gradient promo card inside the panel highlights a campaign or call-to-action
  • Large site headers: arrow-key navigation works across the panel and it stacks neatly on mobile

Accessibility

The navbar is a nav with aria-label="Primary". The Products toggle is a real button; Bootstrap updates its aria-expanded state, and the panel is linked to it with aria-labelledby. Each column list is labelled by its heading through aria-labelledby. Arrow keys move between items, Escape closes the panel and returns focus to the toggle. Icons are aria-hidden. Links and buttons show a 2px accent outline on :focus-visible, and transitions are removed under prefers-reduced-motion.

Usage notes

Requires Bootstrap 5.3 with its JS bundle (added automatically) and Bootstrap Icons. If you need two mega menus, repeat the li.dropdown.mgm-static block with a new toggle id and update its aria-labelledby.

Bootstrap Mega Menu Dropdown at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Mega Menus
License
Free for personal and commercial use

Questions about this template

Can I use the Bootstrap Mega Menu Dropdown code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Bootstrap Mega Menu Dropdown – free Bootstrap 5 mega menu template
Bootstrap Mega Menu Dropdown · free Bootstrap 5 mega menu template

More Mega Menus

Products Mega Menu – free Tailwind CSS mega menu template

Products Mega Menu

Tailwind CSS mega menu with two columns of product links, icons and descriptions, a featured promo card and full keyboard support.