Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
accessible-menu-bootstrap-5
Advanced tools
A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 5.
A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 5.
This project is an extension of accessible-menu to allow out-of-the-box for Bootstrap 5 compatibility.
The supported menu types are:
Chrome | Firefox | Safari | Edge | Chromium | Webkit |
---|---|---|---|---|---|
last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
Found something that doesn't work the way it should in one of the listed browsers above? Open an issue!
NPM is recommended for large-scale development, since it works well with bundlers like Webpack or Rollup.
# latest stable
npm install accessible-menu-bootstrap-5
For learning/prototyping purposes you can use the latest version with:
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5/dist/accessible-menu-bs5.js"></script>
For production environments, it is recommend to use a specific version to avoid unforseen breaking changes:
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.4/dist/accessible-menu-bs5.min.js"></script>
To use accessible-menu-bootstrap-5, you first need to make sure your menu matches the following structure:
<ul id="example-menu" class="navbar-nav">
<li class="nav-item"><a href="/about" class="nav-link">About</a></li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle">Projects ▼</a>
<ul class="dropdown-menu">
<li class="nav-item"><a href="/projects/awesome" class="dropdown-item">Awesome project</a></li>
<li class="nav-item"><a href="/projects/not-so-awesome" class="dropdown-item">Not-so-awesome project</a></li>
</ul>
</li>
<li class="nav-item"><a href="/contact" class="nav-link">Contact me</a></li>
</ul>
Include accessible-menu-bootstrap-5 through import or bundled library in your project:
import AccessibleMenu from "accessible-menu-bootstrap-5";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.4/dist/accessible-menu-bs5.min.js"></script>
Once you have accessible-menu-bootstrap-5 loaded, declare a new menu object.
menuElement
is required for all menus. Unlike accessible-menu, accessible-menu-bootstrap-5 will automatically find dropdown menus since the classes .dropdown
, .dropdown-menu
, and .dropdown-item
are included in the Bootstrap 5 framework.
const menu = new AccessibleMenu.DisclosureMenu({
menuElement: document.querySelector("#example-menu"),
});
Bundled versions of each menu are provided in the dist and individual exports are provided in the index.
There are also compiled ES Module versions if you don't want to use an iife!
import { Bootstrap5DisclosureMenu } from "accessible-menu-bootstrap-5";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.4/dist/disclosure-menu-bs5.min.js"></script>
then
const menu = new Bootstrap5DisclosureMenu({
menuElement: document.querySelector("#example-menu"),
});
import { Bootstrap5Menubar } from "accessible-menu-bootstrap-5";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.4/dist/menubar-bs5.min.js"></script>
then
const menu = new Bootstrap5Menubar({
menuElement: document.querySelector("#example-menu"),
});
import { Bootstrap5Treeview } from "accessible-menu-bootstrap-5";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-5@1.0.4/dist/treeview-bs5.min.js"></script>
then
const menu = new Bootstrap5Treeview({
menuElement: document.querySelector("#example-menu"),
});
Bootstrap 5 has it's own implementation of expanding/collapsing menus using the data-bs-toggle
attribute on navbar togglers and dropdown toggles which would cause both accessible-menu-bootstrap-5 and Bootstrap's own toggler to open/close menus at the same time. To resolve this issue, accessible-menu-bootstrap-5 removed the data-bs-toggle
attributes from menu toggles that it controls.
This project isn't designed to work with other versions of Bootstrap other than v4, however you could probably get it to work with Bootstrap 3 by customizing the selectors and open/close classes when declaring the menu.
You also might be able to get this to work with Bootstrap 5, however v5 changed the data-bs-toggle
value on dropdowns to data-bs-toggle
which won't be handled by this project. A Bootstrap 5 specific project may be created if there is enough interest in it.
This project uses Semantic Versioning 2.0.0 to keep track of releases.
For more detailed information about SemVer, please see the official documentation.
If you're interested in contributing to the project, please read the Contribution Guidelines. Any and all contributions must follow these guidelines or they will not be accepted.
FAQs
A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 5.
The npm package accessible-menu-bootstrap-5 receives a total of 57 weekly downloads. As such, accessible-menu-bootstrap-5 popularity was classified as not popular.
We found that accessible-menu-bootstrap-5 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.