
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
Advanced tools
A JavaScript library to help you generate WCAG accessible menus in the DOM.
A JavaScript library to help you generate WCAG accessible menus in the DOM.
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
For learning/prototyping purposes you can use the latest version with:
<script src="https://cdn.jsdelivr.net/npm/accessible-menu/dist/accessible-menu.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@3.0.7/dist/accessible-menu.min.js"></script>
Check out the upgrade guide!
To use accessible-menu, you first need to make sure your menu matches the following structure:
<ul id="example-menu">
<li><a href="/about">About</a></li>
<li class="dropdown">
<a href="#">Projects ▼</a>
<ul>
<li><a href="/projects/awesome">Awesome project</a></li>
<li><a href="/projects/not-so-awesome">Not-so-awesome project</a></li>
</ul>
</li>
<li><a href="/contact">Contact me</a></li>
</ul>
Include accessible-menu through import or bundled library in your project:
import AccessibleMenu from "accessible-menu";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu@3.0.7/dist/accessible-menu.min.js"></script>
Once you have accessible-menu loaded, declare a new menu object.
menuElement
is required for all menus, while submenuItemSelector
is only required if you have submenus/dropdowns.
const menu = new AccessibleMenu.DisclosureMenu({
menuElement: document.querySelector("#example-menu"),
submenuItemSelector: "li.dropdown",
});
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 { DisclosureMenu } from "accessible-menu";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu@3.0.7/dist/disclosure-menu.min.js"></script>
then
const menu = new DisclosureMenu({
menuElement: document.querySelector("#example-menu"),
submenuItemSelector: "li.dropdown",
});
import { Menubar } from "accessible-menu";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu@3.0.7/dist/menubar.min.js"></script>
then
const menu = new Menubar({
menuElement: document.querySelector("#example-menu"),
submenuItemSelector: "li.dropdown",
});
import { Treeview } from "accessible-menu";
or
<script src="https://cdn.jsdelivr.net/npm/accessible-menu@3.0.7/dist/treeview.min.js"></script>
then
const menu = new Treeview({
menuElement: document.querySelector("#example-menu"),
submenuItemSelector: "li.dropdown",
});
Looking for a working example of accessible-menu? Check out these codepens:
Looking to use this with Bootstrap? Because Bootstrap adds classes to the menu's containing element to show/hide the menu, you'll need custom open/close functions for your menu. Check out the accessible-menu-bootstrap-4 or accessible-menu-bootstrap-5 projects where all that is done for you!
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 WCAG accessible menus in the DOM.
The npm package accessible-menu receives a total of 954 weekly downloads. As such, accessible-menu popularity was classified as not popular.
We found that accessible-menu 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
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.