
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
accessible-menu-bootstrap-4
Advanced tools
A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 4.
A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 4.
This project is an extension of accessible-menu to allow out-of-the-box for Bootstrap 4 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-4
For learning/prototyping purposes you can use the latest version with:
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-4/dist/accessible-menu-bs4.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-4@1.0.4/dist/accessible-menu-bs4.min.js"></script>
To use accessible-menu-bootstrap-4, 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-4 through import or bundled library in your project:
import AccessibleMenu from "accessible-menu-bootstrap-4";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-4@1.0.4/dist/accessible-menu-bs4.min.js"></script>
Once you have accessible-menu-bootstrap-4 loaded, declare a new menu object.
menuElement
is required for all menus. Unlike accessible-menu, accessible-menu-bootstrap-4 will automatically find dropdown menus since the classes .dropdown
, .dropdown-menu
, and .dropdown-item
are included in the Bootstrap 4 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 { Bootstrap4DisclosureMenu } from "accessible-menu-bootstrap-4";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-4@1.0.4/dist/disclosure-menu-bs4.min.js"></script>
then
const menu = new Bootstrap4DisclosureMenu({
menuElement: document.querySelector("#example-menu"),
});
import { Bootstrap4Menubar } from "accessible-menu-bootstrap-4";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-4@1.0.4/dist/menubar-bs4.min.js"></script>
then
const menu = new Bootstrap4Menubar({
menuElement: document.querySelector("#example-menu"),
});
import { Bootstrap4Treeview } from "accessible-menu-bootstrap-4";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-4@1.0.4/dist/treeview-bs4.min.js"></script>
then
const menu = new Bootstrap4Treeview({
menuElement: document.querySelector("#example-menu"),
});
Bootstrap 4 has it's own implementation of expanding/collapsing menus using the data-toggle
attribute on navbar togglers and dropdown toggles which would cause both accessible-menu-bootstrap-4 and Bootstrap's own toggler to open/close menus at the same time. To resolve this issue, accessible-menu-bootstrap-4 removed the data-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-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.
1.0.4 (2023-06-30)
FAQs
A JavaScript library to help you generate WAI-ARIA accessible menus with in the DOM using Bootstrap 4.
The npm package accessible-menu-bootstrap-4 receives a total of 47 weekly downloads. As such, accessible-menu-bootstrap-4 popularity was classified as not popular.
We found that accessible-menu-bootstrap-4 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.