Creating fully accessible tabs
bower install a11y-tabs
tabSelector
({String} [required]): The selector for the tab elements. This selector will be qualified withinthis
(the tab container) (Defaults to'li'
)panelSelector
({String} [required]): The selector for the panel elements. This selector will be qualified withindocument.body
. (Defaults to'.panels li'
)activeClass
({String} [optional]): The class which determines the initally active tab / the class to be added to a newly activated tab. (Defaults to'active'
)inactiveClass
({String} [optional]): The class to be added to a newly inactive tab. (Defaults tonull
)panelShow
({Function} [optional]): The function that is called when a given panel's tab is activated. The element ref to the given panel is passed in as the only parameter. (Defaults tofunction (panel) { panel.style.display = 'block'; }
)panelHide
({Function} [optional]): The function that is called when a given panel's tab is made inactive. The element ref to the given panel is passed in as the only parameter. (Defaults tofunction (panel) { panel.style.display = 'none'; }
)
// call a11yTabs on the tab container
$('.tabs').a11yTabs({
tabSelector: 'li.tab',
panelSelector: '.panel',
activeClass: 'tab-active',
inactiveClass: 'tab-inactive',
panelShow: function (panel) {
$(panel).show().data('showing', true);
},
panelHide: function (panel) {
$(panel).hide().data('showing', false);
}
});
run tests with the command gulp test
Out of the box, you can find an example (build/example.html
) which contains a simple call to a11yTabs
. If you'd like to play around with the options you can edit templates/example.jade
as well as styles/example.styl
and run gulp
which will build the template and stylus file into the build directory.
- Protip: When editing examples, it may be useful to run
gulp watch
so you don't have to manually executegulp
every time you make a jade or stylus change.