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
- Add a link: copy one
<li>inside.mega-gridand change the link, the title and the one-line text. - Add a category: add one
.mega-tabwith a newdata-mega-tabvalue and one.mega-panelwith the same value indata-mega-panel. - Use it for something else: the same markup works for a services or locations menu. Replace the promo card with a banner or a contact card.
- Search: typing in the box looks through every link of every category. Escape clears it.
- Screen sizes: under 1200px the promo card is hidden and the links use two columns. Under 992px the desktop menu is hidden and the mobile menu shows a plain list.
- Mobile: add a collapse item to the mobile menu with links to the components hub and the documentation.
- Component pages: they copy this header from
index.html. After editing the menu, runnode build-docs-header.js. - "New" label: add
<em class="mega-new">New</em>after the title.
Classes and attributes
| Name | Purpose |
|---|---|
li.has-mega | Menu 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-rail | Left column with search and tabs. |
.mega-tab / data-mega-tab | A category button. Hover, focus or click shows its panel. |
.mega-panel / data-mega-panel | The links of one category. |
.mega-grid / .mega-link | Three-column link grid. Each link has an icon, a title and a short text. |
.mega-new | Small gold "New" label. |
.mega-promo | Dark card on the right, used for the documentation. |
.mega-empty | Message shown when the search finds nothing. |