npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

accessible-menu-bootstrap-4

v1.0.4

Published

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

Downloads

237

Readme

accessible-menu-bootstrap-4

Latest release License Jest tests GitHub CodeQL

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

This project is an extension of accessible-menu to allow out-of-the-box for Bootstrap 4 compatibility.

The supported menu types are:

Browser Support

| 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!

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-bootstrap-4

CDN

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

<script src="https://cdn.jsdelivr.net/npm/accessible-menu-bootstrap-4/dist/accessible-menu-bs4.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/[email protected]/dist/accessible-menu-bs4.min.js"></script>

Usage

To use accessible-menu-bootstrap-4, you first need to make sure your menu matches the following structure:

<ul id="example-menu" class="navbar-nav">
  <li class="nav-item"><a href="/about" class="nav-link">About</a></li>
  <li class="nav-item dropdown">
    <a href="#" class="nav-link dropdown-toggle">Projects ▼</a>
    <ul class="dropdown-menu">
      <li class="nav-item"><a href="/projects/awesome" class="dropdown-item">Awesome project</a></li>
      <li class="nav-item"><a href="/projects/not-so-awesome" class="dropdown-item">Not-so-awesome project</a></li>
    </ul>
  </li>
  <li class="nav-item"><a href="/contact" class="nav-link">Contact me</a></li>
</ul>

Include accessible-menu-bootstrap-4 through import or bundled library in your project:

import AccessibleMenu from "accessible-menu-bootstrap-4";

or

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/accessible-menu-bs4.min.js"></script>

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

menuElement is required for all menus. Unlike accessible-menu, accessible-menu-bootstrap-4 will automatically find dropdown menus since the classes .dropdown, .dropdown-menu, and .dropdown-item are included in the Bootstrap 4 framework.

const menu = new AccessibleMenu.DisclosureMenu({
  menuElement: document.querySelector("#example-menu"),
});

Only need one type of menu class?

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!

Bootstrap4DisclosureMenu usage

import { Bootstrap4DisclosureMenu } from "accessible-menu-bootstrap-4";

or

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/disclosure-menu-bs4.min.js"></script>

then

const menu = new Bootstrap4DisclosureMenu({
  menuElement: document.querySelector("#example-menu"),
});

Bootstrap4Menubar usage

import { Bootstrap4Menubar } from "accessible-menu-bootstrap-4";

or

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/menubar-bs4.min.js"></script>

then

const menu = new Bootstrap4Menubar({
  menuElement: document.querySelector("#example-menu"),
});

Bootstrap4Treeview usage

import { Bootstrap4Treeview } from "accessible-menu-bootstrap-4";

or

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/treeview-bs4.min.js"></script>

then

const menu = new Bootstrap4Treeview({
  menuElement: document.querySelector("#example-menu"),
});

Documentation

Conflict with Bootstrap's own navbar toggle

Bootstrap 4 has it's own implementation of expanding/collapsing menus using the data-toggle attribute on navbar togglers and dropdown toggles which would cause both accessible-menu-bootstrap-4 and Bootstrap's own toggler to open/close menus at the same time. To resolve this issue, accessible-menu-bootstrap-4 removed the data-toggle attributes from menu toggles that it controls.

Other versions of Bootstrap

This project isn't designed to work with other versions of Bootstrap other than v4, however you could probably get it to work with Bootstrap 3 by customizing the selectors and open/close classes when declaring the menu.

You also might be able to get this to work with Bootstrap 5, however v5 changed the data-toggle value on dropdowns to data-bs-toggle which won't be handled by this project. A Bootstrap 5 specific project may be created if there is enough interest in it.

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.

Sponsors