Quick start guide and documentation
<head>)
</body>)
Add aria-haspopup="true" to the parent link and nest a .rsl-navbar-dropdown list:
Products
Nest dropdowns within dropdowns for multi-level menus:
Services
fa-chevron-down for top-level dropdowns and fa-chevron-right for nested dropdowns.
Create rich, multi-column dropdowns with arbitrary HTML content. Perfect for complex navigation with images, descriptions, and custom layouts:
Solutions
data-menu-type="mega" to the .rsl-navbar-item.rsl-navbar-mega-menu instead of .rsl-navbar-dropdown.slot-layout for responsive columns.mega-section - Container for each column section.mega-description - Secondary descriptive text.mega-featured - Highlighted/featured content box.full-width - Make mega menu full viewport widthAdd .dark-theme for a dark background with light text:
Add .primary-theme for a branded purple background:
Control how dropdowns open using the data-hover-dropdowns attribute:
| Attribute | Behavior |
|---|---|
| No attribute (default) | Click-only mode: Dropdowns open only on click (all screen sizes) |
data-hover-dropdowns="true" |
Hover mode: Dropdowns open on hover for desktop (>768px), click for mobile |
Control the logo and menu positioning using the data-layout attribute:
| Attribute | Layout |
|---|---|
| No attribute (default) | Logo left, menu links right |
data-layout="logo-right" |
Logo right, menu links left |
data-layout="logo-center" |
Logo center, menu links split left and right (automatically divided) |
| Class | Behavior |
|---|---|
.sticky-top |
Sticks to top when scrolling |
.sticky-bottom |
Sticks to bottom when scrolling |
.fixed-top |
Always fixed at top |
.fixed-bottom |
Always fixed at bottom |
| Method | Description |
|---|---|
RSL.Navbar.init() |
Initialize all navbars (runs automatically on page load) |
RSL.Navbar.open(element) |
Open a specific dropdown menu item |
RSL.Navbar.close(element) |
Close a specific dropdown menu item |
RSL.Navbar.toggle(element) |
Toggle a dropdown menu item |
RSL.Navbar.closeAll() |
Close all open dropdowns |
// Get a menu item
const menuItem = document.querySelector('.rsl-navbar-item');
// Open dropdown
RSL.Navbar.open(menuItem);
// Close dropdown
RSL.Navbar.close(menuItem);
// Toggle dropdown
RSL.Navbar.toggle(menuItem);
// Close all dropdowns
RSL.Navbar.closeAll();
Tab - Move focus between menu items (and within mega menus)Arrow Keys - Navigate within regular dropdowns (not mega menus)Enter / Space - Activate link or toggle dropdown/mega menuEscape - Close dropdown/mega menu and return focus, or close mobile menuHome / End - Jump to first/last item in regular dropdownsaria-expanded state managementrole="button" for dropdown triggersCustomize the navbar by overriding these CSS variables:
| Variable | Default | Description |
|---|---|---|
--navbar-bg |
#ffffff | Background color |
--navbar-text |
#333333 | Text color |
--navbar-hover-bg |
#f5f5f5 | Hover background |
--navbar-active-bg |
#6E7BFF | Active item background |
--navbar-height |
60px | Navbar height |
--navbar-z-index |
10000 | Base z-index |
:root {
--navbar-bg: #2c3e50;
--navbar-text: #ecf0f1;
--navbar-active-bg: #e74c3c;
}
navbar.js is loaded after the navbar HTMLaria-haspopup="true" is on parent links.rsl-navbar-toggle button is presentnavbar.css is loaded.sticky-top or .fixed-top for elevated z-index (10100)--navbar-z-index if conflicts occurOpen navbar.html in your browser
Use playground.html as a template
Complete keyboard navigation, ARIA support, and focus management built-in