1. Install and import the accessible-menu with NPM.
# NPM $ npm install accessible-menu --save
// All-in-one
import AccessibleMenu from 'accessible-menu';
// Disclosure Menu
import { DisclosureMenu } from "accessible-menu";
// Horizontal Menu Bar
import { Menubar } from "accessible-menu";
// Vertical Tree Menu
import { Treeview } from "accessible-menu"; 2. Or include the UMD versions on the page as follows:
<!-- All-in-one --> <script src="/path/to/dist/accessible-menu.min.js"></script> <!-- Disclosure Menu --> <script src="/path/to/dist/disclosure-menu.min.js"></script> <!-- Horizontal Menu Bar --> <script src="/path/to/dist/menubar.min.js"></script> <!-- Vertical Tree Menu --> <script src="/path/to/dist/treeview.min.js"></script>
3. The HTML structure for the accessible dropdown menu.
<nav id="main-nav" aria-label="Main">
<!-- Toggle Button (Available For Menubar or DisclosureMenu) -->
<button id="main-menu-toggle" aria-label="Toggle main menu">☰</button>
<!-- Main Menu (Available For Menubar or DisclosureMenu) -->
<ul id="main-menu">
<li>
<a href="#">Home</a>
</li>
<li class="dropdown">
<a href="#">Category ▼</a>
<ul>
<li>
<a href="#">JavaScript</a>
</li>
<li>
<a href="#">CSS</a>
</li>
</ul>
</li>
<li>
<a href="#">Contact</a>
<a href="#">About</a>
</li>
</ul>
</nav> 4. Create a disclosure menu.
const menu = new DisclosureMenu({
menuElement: document.querySelector("#main-menu"),
submenuItemSelector: ".dropdown",
controllerElement: document.querySelector("#main-menu-toggle"),
containerElement: document.querySelector("#main-nav"),
openClass: "open",
}); 5. Create a menu bar.
const menu = new Menubar({
menuElement: document.querySelector("#main-menu"),
submenuItemSelector: ".dropdown",
controllerElement: document.querySelector("#main-menu-toggle"),
containerElement: document.querySelector("#main-nav"),
openClass: "open",
}); 6. Create a vertical tree menu.
const menu = new Treeview({
menuElement: document.querySelector("#main-menu"),
submenuItemSelector: ".dropdown",
}); 7. Apply your own styles to the menu as seen in our examples.
6. All possible parameters:
v4.2.2 (05/27/2025)
v4.2.1 (03/09/2025)
11/11/2024
v4.2.0 (11/08/2024)
v4.1.2 (08/01/2024)
v4.1.1 (08/01/2024)
v4.1.0 (06/25/2024)
v4.0.1 (03/05/2024)
v4.0.0 (07/01/2023)
v3.0.8 (07/01/2023)
v3.0.7 (06/30/2023)
v3.0.6 (06/23/2023)
v3.0.5 (02/10/2023)
v3.0.4 (11/30/2021)
v3.0.3 (11/11/2021)
v3.0.2 (10/27/2021)
v3.0.1 (10/19/2021)
v3.0.0 (08/04/2021)
v2.3.1 (06/11/2021)
v2.3.0 (06/07/2021)
v2.2.0 (03/25/2021)
v2.1.1 (03/23/2021)
v2.1.0 (07/25/2020)
07/18/2020
05/23/2020
05/20/2020
05/09/2020
05/07/2020
The post WCAG Compliant Responsive Dropdown Navigation – accessible-menu appeared first on CSS Script.
Frauds are no longer spotted by disorganized phishing emails that contain spelling errors. They are…
Microsoft is actively investigating a widespread authentication issue affecting users attempting to access Microsoft 365…
Two American nationals have been sentenced to federal prison for operating a sophisticated “laptop farm”…
A threat cluster tracked as UAC-0247 has been running an active campaign since early 2026,…
FORT WAYNE, IND. (WOWO) Indiana Governor Mike Braun is weighing in on multiple contested primary races…
The internet definitely had some thoughts about Jared Leto’s Skeletor voice when the first Masters…
This website uses cookies.