The main menu component helps users understand what the main sections of the website are, what the website is about and what they can find or do on the website.
Use the main menu component to offer one-click access to top tasks and/or the main sections of the website and to help users understand what the website is about and what they can find or do on the website.
A main menu is required for most websites.
When a menu menu is used, the main menu should be included:
Do not use the main menu component on:
A main menu is composed as follows:
This is a Javascript enabled molecule. Please check the javascript documentation on how to implement this correctly in your project.
{% set modalContent %}
<div class="header">
{% include '@logo' %}
</div>
{% if items and items.length > 0 %}
<div class="menu-links">
{% include '@list' with {
type: 'links',
items: items
} %}
</div>
{% endif %}
{{ translate }}
{% endset %}
<nav class="menu">
<button type="button"
class="modal-trigger toggle"
aria-expanded="false"
aria-controls="{{ id }}">menu
</button>
{% if items and items.length > 0 %}
{% include '@list' with {
type: 'links',
items: items
} %}
{% endif %}
{% include "@modal" with {
title_heading_level: 'span',
id: id,
classes: 'has-custom-binding menu',
content: modalContent
} %}
</nav>
<nav class="menu">
<button type="button" class="modal-trigger toggle" aria-expanded="false" aria-controls="menu">menu
</button>
<ul class="">
<li><a href="#" class="active">Home</a></li>
<li><a href="#">Menu item 1</a></li>
<li><a href="#">Menu item 2</a></li>
<li><a href="https://www.google.com">Google</a></li>
</ul>
<div id="menu" class="modal has-custom-binding menu" role="dialog" aria-modal="true" tabindex="-1">
<div class="modal-inner">
<div class="modal-header">
<button class="button button-secondary close icon-cross modal-close" data-target="menu">
<span>Close</span>
</button>
</div>
<div class="modal-content">
<div class="header">
<a href="#" title="Home" class="site-logo " rel="home">
</a>
</div>
<div class="menu-links">
<ul class="">
<li><a href="#" class="active">Home</a></li>
<li><a href="#">Menu item 1</a></li>
<li><a href="#">Menu item 2</a></li>
<li><a href="https://www.google.com">Google</a></li>
</ul>
</div>
</div>
</div>
<div class="modal-overlay modal-close" data-target="menu" tabindex="-1"></div>
</div>
</nav>
{
"items": [
"<a href=\"#\" class=\"active\">Home</a>",
"<a href=\"#\">Menu item 1</a>",
"<a href=\"#\">Menu item 2</a>",
"<a href=\"https://www.google.com\">Google</a>"
],
"id": "menu"
}
nav.menu {
margin: 0;
button {
@include button-icon;
padding: 0;
border: 0;
background: transparent;
font-size: .8rem;
@include tablet {
display: none;
}
&::before {
order: 0;
margin-right: 10px;
margin-left: 0;
}
&.toggle {
@include icon(hamburger);
}
&.close {
@include icon(cross);
}
}
ul {
@extend %list-no-style;
@include tablet-and-below {
display: none;
}
margin: 0;
li {
display: inline-block;
margin-right: 20px;
a,
a[href^="mailto:"],
a[download],
a[href^="http://"]:not([href*="gent.be"]),
a[href^="https://"]:not([href*="gent.be"]) {
@include reset-link-background;
@include link-underlined;
margin-bottom: 0;
padding: 10px 0;
}
a.active {
@include bold-text;
}
}
}
}
.modal.menu {
@include tablet {
display: none;
}
.modal-inner {
.modal-header {
position: absolute;
right: 0;
margin-top: 20px;
margin-right: 10px;
z-index: 7;
}
}
.modal-content {
flex: 1;
padding: 0;
.header {
position: relative;
margin: 12px $gutter-width;
&::before {
@include theme('border-color', 'color-primary--lighten-4', 'header-border-bottom');
position: absolute;
top: 100%;
left: -30px;
width: 100vw;
height: 20px;
margin-top: 12px;
border-top: 2px solid;
content: '';
}
button {
position: absolute;
right: 0;
margin-top: 5px;
}
}
.menu-links {
ul {
@extend %list-no-style;
margin: 0;
li {
@include tablet {
display: inline-block;
margin-right: 20px;
}
@include theme('border-color', 'color-primary-light');
margin-bottom: 0;
border-bottom: 1px solid;
a,
a[href^="mailto:"],
a[download],
a[href^="http://"],
a[href^="https://"] {
@include reset-link-background;
@include icon('chevron-right', 'after');
display: block;
padding: 10px 20px;
line-height: 1.4rem;
&:hover {
@include theme('background-color', 'color-primary-light');
}
&::after {
position: absolute;
top: 50%;
right: 30px;
margin-top: -13px;
}
}
a.active {
@include bold-text;
}
}
}
}
.language-switcher {
display: block;
margin: 0 24px;
&:not(:last-child) {
@include theme('border-color', 'color-primary--lighten-4');
border-bottom: 2px solid;
}
ul {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin: 0;
padding: 12px 0;
li {
padding: 12px;
}
}
}
}
}
'use strict';
(function () {
if (!Modal) { // eslint-disable-line no-undef
return;
}
const menu = document.querySelectorAll('.modal.menu');
const createModal = function (modal) {
// eslint-disable-next-line no-undef
new Modal(modal, {
// The modal is always visible from tablet and up,
// this is atypical.
resizeEvent: (open, close) => {
if (window.innerWidth > 960) {
close();
modal.setAttribute('aria-hidden', 'false');
}
else {
if (!modal.classList.contains('visible')) {
modal.setAttribute('aria-hidden', 'true');
}
}
}
});
};
for (var i = menu.length; i--;) {
createModal(menu[i]);
}
})();