- Uses ARIA States and Properties
- AMD/CommonJS module support
aria-collapsible is also really tiny:
|Minified and gzipped||597 bytes|
Adding aria-collapsible to your project is easy! You've got a couple options:
- Download a tagged version from GitHub and do it yourself (old school).
- Install via Bower:
bower install aria-collapsible
- Install via npm:
npm install aria-collapsible
To use aria-collapsible, your markup needs two elements: a control and a region. The control, typically a
<button> or an
<a> element, is what your user will interact with and is the element that controls the display of the collapsible region. The region is an element elsewhere on the page whose display is handled by the control.
The two elements are associated by adding an
aria-controls="region" attribute to the control. The value of the
aria-controls attribute corresponds to the value of the region's
MenuChapter 1Chapter 2Chapter 3Chapter 4Chapter 5
Most browsers don't natively hide elements with the
aria-hidden attribute so you'll need to add the following to your stylesheet:
Lastly, initialize aria-collapsible by creating a
new Collapsible, passing in a DOM reference to the control, and calling the
var collapsible = document;collapsible;
You can see the above in action in the included example file.
Collapsible regions can be shown and hidden programatically using the
You can also teardown a collapsible region, resetting the DOM to its initial state and removing event handlers:
aria-collapsible works in all modern browsers.
if 'addEventListener' in window// Your scripts here…
aria-collapsible is inspired by the following works:
- Steve Faulkner's article, HTML5 Accessibility Chops: hidden and aria-hidden
- Heydon Pickering's Progressive collapsibles demo
- Nicolas Hoffman's jQuery collapsible regions plugin
aria-collapsible is freely available under The MIT License. Go forth and make the Web a more accessible place.