1. Import the Clicky Menus into the HTML.
<link rel="stylesheet" href="./clicky-menus.css" /> <script src="./clicky-menus.js"></script>
2. Create a dropdown menu from a nested nav list as follows. That’s it.
<!-- for use with <use> -->
<svg xmlns="http://www.w3.org/2000/svg" hidden>
<symbol id="arrow" viewbox="0 0 16 16" >
<polyline points="4 6, 8 10, 12 6" stroke="#000" stroke-width="2" fill="transparent" stroke-linecap="round" />
</symbol>
</svg>
<!-- In the real world, all hrefs would have go to real, unique URLs, not a "#" -->
<nav id="site-navigation" class="site-navigation" aria-label="Clickable Menu Demonstration">
<ul class="main-menu clicky-menu no-js">
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">
Category
<svg aria-hidden="true" width="16" height="16">
<use xlink:href="#arrow" />
</svg>
</a>
<ul>
<li><a href="#">Accordion</a></li>
<li><a href="#">Carousel</a></li>
<li><a href="#">Dropdown</a></li>
<li><a href="#">Menu</a></li>
<li><a href="#">Navigation</a></li>
</ul>
</li>
<li>
<a href="#">
Social
<svg aria-hidden="true" width="16" height="16">
<use xlink:href="#arrow" />
</svg>
</a>
<ul>
<li><a href="#">Facebook</a></li>
<li><a href="#">Twitter</a></li>
<li><a href="#">Linkedin</a></li>
<li><a href="#">Instagram</a></li>
</ul>
</li>
<li>
<a href="#">
About
<svg aria-hidden="true" width="16" height="16">
<use xlink:href="#arrow" />
</svg>
</a>
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Policy</a></li>
<li><a href="#">Contact</a></li>
</ul>
</li>
</ul>
</nav> 3. Enable an element to close the opened submenu.
<button data-clicky-menus-close="my-menu">Close Open Submenus</button>
v1.3.0 (04/26/2025)
v1.2.0 (05/22/2024)
11/08/2022
The post Accessible Dropdown Nav With Vanilla JavaScript – Clicky Menus appeared first on CSS Script.
Spot fire contained after Westover burn WESTOVER AIR RESERVE BASE — Firefighters from Westover and…
50 Years Ago Hampshire County officials say that they have viewed 11 sites other than…
A Street Fighter movie trailer was released as part of CinemaCon 2026, showing off new…
Lee Cronin’s The Mummy hits theaters on April 17.Lee Cronin’s The Mummy is, for better…
To help celebrate Star Wars Day / May the 4th, Dairy Farmers of America (DFA)…
Netflix and Sony Pictures have announced Charlie vs. the Chocolate Factory, a new take on…
This website uses cookies.