JSPM

  • Created
  • Published
  • Downloads 1430
  • Score
    100M100P100Q108418F
  • License ISC

A JavaScript library to help you generate WAI-ARIA accessible menus in the DOM.

Package Exports

  • accessible-menu

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (accessible-menu) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

accessible-menu

Latest release License

A JavaScript library to help you generate WAI-ARIA accessible menus in the DOM.

Browser Support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Opera
Opera
IE11, Edge * last 2 versions last 2 versions last 2 versions last 2 versions last 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@1.0.2/dist/accessibleMenu.js"></script>

Usage

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

<menu>
    <menu-item><a>...</a></menu-item>
    <menu-item-with-dropdown>
        <dropdown-toggle />
        <dropdown-menu>
            <menu-item><a>...</a></menu-item>
            ...
        </dropdown-menu>
    </menu-item-with-dropdown>
    <menu-item><a>...</a></menu-item>
    ...
</menu>

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({
    menuElement: menuDOMObject,
    menuItemSelector: "menu-item-css-selector",
    submenuItemSelector: "menu-item-with-dropdown-css-selector",
    submenuToggleSelector: "dropdown-toggle-css-selector",
    submenuSelector: "dropdown-menu-css-selector",
    openClass: "class-to-open-menus"
});

Documentation

Internet Explorer and Edge Support

For both IE and Edge support, you will either need to use the CDN option, or run your code through Babel.

For IE, you will also need to ensure you load Babel Polyfill before loading accessible-menu.

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.