jQuery Accessible Carrousel System, using ARIA

Find/fork me on Github

Other accessible plugins

The jQuery plugin will transform a simple list of div’s and hx into a fantastic-shiny carrousel system, using ARIA.

Here are how-to-use and some examples of this plugin.

Last updates

15th of September 2017:

Show controls only when there are more than one .carrousel_content, thanks to @harrinsonmb.


A first and “standard” example

A robust base

  • This carrousel is based on simple div’s, so your page will be working even without JavaScript!
  • The code that it produces is valid and semantic.
  • It is entirely modular, quite easy to use and customise.

How it is working

Then it adds buttons

A div with a button is inserted between carrousel contents and the first control list. It is the “previous” button.
Another one is inserted after all carrousel contents, for the… “next” button.


How to use it

Here is the starting code needed. Just add jQuery and the plugin, needed CSS, style it as you want, and it is ok.

<div class="carrousel relative">      
  <div class="carrousel__container mod--hidden" 
   data-carrousel-btn-previous-img="./arrow_back.png" 
   data-carrousel-btn-next-img="./arrow_next.png"
   data-carrousel-btn-previous-text="Show previous panel"
   data-carrousel-btn-next-text="Show next panel"
   data-carrousel-prefix-classes="news"
   data-carrousel-span-text-class="invisible"
   data-carrousel-transition="fade"
   data-carrousel-existing-hx="h3">
          
    <div class="carrousel__content">
      <h3>A first panel</h3>
      <p>Here the content.</p>
    </div><!--
 --><div class="carrousel__content">
      <h3>A second panel</h3>
      <p>Here the content.</p>
    </div><!--
 --><div class="carrousel__content">
      <h3>A third panel</h3>
      <p>Here the content.</p>
    </div>
          
  </div>
</div>

You may also use npm i jquery-accessible-carrousel-aria.

Important note: for accessibility purposes (for VoiceOver), the plugin has to give focus to hx (h2, h3, h4, etc.) in tab contents. It is better having hx in each content tab.

Other attributes are available:

Usually, I minify my CSS, but for this example, I didn’t.
Go into the CSS and have a look (search “styles for carrousel, examples”), and also in the breakpoints.


Keyboard navigation is supported too, here are keys.

If you focus in the carrousel “buttons” (not next and previous buttons):

If you focus in a carrousel content:

Warning: Ctrl+PageUp/PageDown combination could activate for some browsers a switch of browser tabs. Nothing to do for this, as far as I know (if you have a solution, let me know).


Logic of styling classes added

Major elements are styled like this, example with:

<ol class="js-carrousel__control__list 
           prefix-carrousel__control__list 
           prefix-carrousel__control__list--1"
    role="tablist">