Build Accessible Sliding Hamburger Menus with Offcanvas

The giveaway Offcanvas plugin is one of many resources for shifting navigations. You can find a garland of identical plugins online though Offcanvas stands out for a few reasons.

It’s a fairly lightweight library and while it does run on jQuery it’s also not really formidable to set up. This is loyal for both a JavaScripts formula and a HTML code, so we won’t need to change your default navigation most during all.

Offcanvas hamburger pluginOffcanvas hamburger plugin

The Offcanvas plugin lets we designate certain areas where a menu should appear. By default, this is customarily a left or right side of a screen, though we can also select a tip or bottom of a screen, too.

This creates Offcanvas good for more than only shifting hamburger menus. It can be used for sliding notification bars or even opt-in fields to constraint emails.

Each row works a same approach where a user can click anywhere on a page to censor a shifting menu. And, we can set adult keyboard commands that run agreeable with ARIA discipline for proper web accessibility.

To get Offcanvas installed, we only need a duplicate of jQuery along with a Offcanvas CSS/JS files. You can lift these by npm, bower, or directly from GitHub.

Also on a GitHub page, you’ll see a bit of representation code we can redo to fit your website. All we need for a shifting nav is an aside component containing your menu (or whatever we wish to slip onto a page).

This is triggered by an anchor link indicating towards a ID of your shifting menu. Here’s a dash from a Offcanvas GitHub that illustrates a brief example:

  div class="c-offcanvas-content-wrap"
      a href="#off-canvas" data-offcanvas-trigger="off-canvas"
  aside class="js-offcanvas" id="off-canvas"/aside

script type="text/javascript"
// options

If you’re means to slightly redo a HTML in your page we should have no difficulty removing this all set up.

The offcanvas() duty even supports options for changing a animation speed, default class, and callback functions that can run after a menu opens or closes.

To learn some-more and see a live demo, check out a main plugin page. Offcanvas is a good choice for jQuery-powered navigation if we like hamburger menus.

Sliding Offcanvas menu exampleSliding Offcanvas menu example

Add Comment