
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
The mobile first menu navigation for today's modern web, developed with ES6+ JavaScript, TypeScript definitions and packed with lots of features.
Download the package and check the demo folder, or check it online here.
5kb
in size when minified<button class="navbar-toggle">
element for element visibility toggle<button class="subnav-toggle">
element that enables visibility of the submenusopen-mobile
class to toggle submenus via the click
handlermouseenter
, by adding open
and open-position
classes to the menu item, in rapid successionmouseleave
, by removing the above classes in a delayed succesionOn both mobile and desktop, Navbar.js allows for full keyboard navigation via the TAB and SPACE keys. In addition, directional arrows provide navigation on desktop with RTL support.
You can install this through NPM:
$ npm install navbar.js
Download the latest package. unpack and inspect the contents. You need to copy the navbar.js
and navbar.css
or their minified variations to your app assets
folders as follows.
Link the required CSS in your document <head>
tag
<link href="../assets/css/navbar.css" rel="stylesheet">
Link the required JS in your document <body>
tag, though it should work in the <head>
as well
<script src="../assets/js/navbar.js"></script>
Initiate the function for your elements at the end of your <body>
tag
<script>
var myMenu = new Navbar('selector');
</script>
To use the DATA-API, you need to provide the data-function="navbar"
attribute to your navbar, like so:
<nav class="navbar" data-function="navbar">
<a href="#" title="App Name">Brand Name</a>
<button class="navbar-toggle">
<i class="menu-icon"></i>
</button>
<div>
<ul class="nav">
<li><a href="#">Link Title</a></li>
<li><a href="#">Another Link Title</a></li>
</ul>
</div>
</nav>
Alternatively you can use only the menu itself and use the specific attribute:
<div class="sidebar">
<ul class="nav" data-function="navbar">
<li><a href="#">Link Title</a></li>
<li><a href="#">Another Link</a></li>
</ul>
</div>
Other initialization and markup options apply, explained in the demo.
import Navbar from 'navbar.js'
let myNav = new Navbar('#myNav')
// get and store it
var Navbar = require("navbar.js");
// initialize it
var myMenu = new Navbar('#myNav');
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.