Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

accessible-menu

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accessible-menu

A JavaScript library to help you generate WCAG accessible menus in the DOM.

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
increased by31.86%
Maintainers
1
Weekly downloads
 
Created
Source

accessible-menu

Latest release License

A JavaScript library to help you generate WCAG accessible menus in the DOM.

The two supported menu types are:

Browser Support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Opera
Opera
IE11, Edge *last 2 versionslast 2 versionslast 2 versionslast 2 versionslast 2 versions

Installation

NPM

NPM is recommended for large-scale development, since it works well with bundlers like Webpack or Rollup.

# latest stable
npm install accessible-menu

CDN

For learning/prototyping purposes you can use the latest version with:

<script src="https://cdn.jsdelivr.net/npm/accessible-menu/dist/accessibleMenu.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@2.0.0/dist/accessibleMenu.js"></script>

Usage

To use accessible-menu, you first need to ensure your menu follows a basic menu structure.

<ul>
  <li><a>...</a></li>
  <li class="dropdown">
    <button></button>
    <ul>
      <li><a>...</a></li>
      ...
    </ul>
  </li>
  <li><a>...</a></li>
  ...
</ul>

include the root menu or bundled library in your project:

import AccessibleMenu from "accessible-menu";

or

<script src="path/to/accessible-menu/dist/accessibleMenu.js"></script>

Once you have accessible-menu loaded, simply declare a new menu object.

const menu = new AccessibleMenu.DisclosureMenu({
  menuElement: menuDOMObject,
  menuItemSelector: "li-css-selector",
  menuLinkSelector: "li-css-selector",
  submenuItemSelector: "li-with-dropdown-css-selector",
  submenuToggleSelector: "dropdown-toggle-css-selector",
  submenuSelector: "dropdown-menu-css-selector",
  openClass: "class-to-open-menus",
});

Documentation

Examples

Looking for a working example of accessible-menu? Check out these jsfiddles:

Internet Explorer and Edge Support

For both IE and older (non-chromium-based) versions of Edge support, you will either need to use the CDN option, or run your code through Babel.

If you are compiling your own code without the help of something like Babel + core-js, you will need polyfills for Array.from(), Array.prototype.includes(), Array.find(), and String.prototype.startsWith() for IE11 support.

Versioning

This project uses Semantic Versioning 2.0.0 to keep track of releases.

For more detailed information about SemVer, please see the official documentation.

Contributing

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.

Keywords

FAQs

Package last updated on 25 Jul 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc