A navigation bar helps in navigating across various pages in a website. They are also referred to as a navbar.
Elixir offers a Basic Navigation component which contains the following parts -
Brand logo or title, search bar, navigation links, and an optional hamburger for medium and small screens.
Basic Navigation
The basic navigation consists of a brand name or logo, a search bar, links and an optional hamburger that appears on small/ medium sized screens.
To generate a basic navigation use the following classes:
navigation-bar
for the navigation container.
Other classes include-
navigation-desktop
Contains the navigation components that are displayed in medium to large screens.
navigation-mobile
Contains the search bar to enter the query text that is displayed in smaller screens.
brand-name.logo
Contains the brand name/ logo.
navigation-query
Contains the search bar to enter query text.
navigation-actions
Contains the navigation bar actions or links.
navigation-bar-hamburger
Contains the hamburger icon to open the navigation bar in smaller screens.
btn-navigation-close
Contains the close button to close the navigation bar in smaller screens.
/* Reference to the navigatio bar */const navigation = document.querySelector('.navigation-bar');
/* Reference to the navigatio bar hamburger icon */const navigationHamburger = document.querySelector('.navigation-bar-hamburger');
/* Reference to the navigatio bar close icon*/const navigationCloseButton = document.querySelector('.btn-navigation-close');
/* Attaching listeners on hamburger and navigation close buttons to listen for click event */
navigationHamburger.addEventListener('click', openNavigation);
navigationCloseButton.addEventListener('click', openNavigation);
/* Handler that toggles navigation bar open status */functionopenNavigation(e) {
navigation.classList.toggle('navigation-open');
}