Layout

Mega menu

A wide, searchable menu panel with category tabs, link descriptions and a documentation card.

Structure

A wide panel that opens under the header. It has three parts: a left rail with a search box and category tabs, a middle area with the links of the active category, and a documentation card on the right. See it live in the Components item of the menu on index.html.

<li class="dropdown has-mega">
  <button type="button" class="dropdown-toggle" data-bs-toggle="dropdown"
          data-bs-auto-close="outside" data-bs-display="static" aria-expanded="false">Components</button>
  <div class="dropdown-menu mega" data-mega>
    <div class="mega-inner">
      <div class="mega-rail">
        <div class="mega-search"><svg class="icon">...</svg><input type="search" placeholder="Search components"></div>
        <div class="mega-tabs" role="tablist">
          <button type="button" class="mega-tab is-active" data-mega-tab="foundation">
            <span class="mega-tab-icon"><svg class="icon">...</svg></span>
            <span class="mega-tab-text"><strong>Foundation UI</strong><small>9 components</small></span>
          </button>
          ...more tabs...
        </div>
      </div>
      <div class="mega-body">
        <section class="mega-panel is-active" data-mega-panel="foundation">
          <div class="mega-panel-head"><h3>Foundation UI</h3><p>Short text</p><a class="mega-all" href="#">All components</a></div>
          <ul class="mega-grid">
            <li><a class="mega-link" href="components/button.html">
              <span class="mega-link-icon"><svg class="icon">...</svg></span>
              <span class="mega-link-text"><strong>Button <em class="mega-new">New</em></strong><small>One line description</small></span>
            </a></li>
          </ul>
        </section>
        <p class="mega-empty" hidden>No components match your search.</p>
      </div>
      <aside class="mega-promo">...documentation card...</aside>
    </div>
  </div>
</li>

It opens and closes with the normal Bootstrap dropdown, so no extra library is needed. data-bs-auto-close="outside" keeps it open while you type in the search box, and data-bs-display="static" lets the CSS place it. The tabs and the search come from assets/js/site.min.js (behavior 20).

Instructions

Classes and attributes

NamePurpose
li.has-megaMenu item that holds the panel. Makes the panel as wide as the page, not the item.
.mega / [data-mega]The dropdown panel. The data attribute switches on the tabs and search.
.mega-railLeft column with search and tabs.
.mega-tab / data-mega-tabA category button. Hover, focus or click shows its panel.
.mega-panel / data-mega-panelThe links of one category.
.mega-grid / .mega-linkThree-column link grid. Each link has an icon, a title and a short text.
.mega-newSmall gold "New" label.
.mega-promoDark card on the right, used for the documentation.
.mega-emptyMessage shown when the search finds nothing.