Initialization
window.addEventListener('DOMContentLoaded', () => { new A11yTabs('.tab-list', '[role="tabpanel"]', 0) })
DOM ready
You should ensure you're DOM content has loaded before you attempt to instantiate A11yTabs. This can
be done with window.addEventListener('DOMContentLoaded, () => {}).
A11yTabs parameters
A11yTabs has three parameters in the following order:
tabListSelector(string) is a CSS selector to pointing to your tablist. This element is the parent element of your tab buttons. It must have the attribute[role="tablist"], and the child tab buttons must in turn have the attributerole="tab". These tab buttons should also contain thearia-controlsattribute pointing to the ID of a corresponding tab-panel to be opened when that tab button is selected. For example:
<div role="tablist">
<button class="tab-item tab-button" role="tab" aria-controls="panel-1">Tab 1</button>
<button class="tab-item tab-button" role="tab" aria-controls="panel-2">Tab 2</button>
...and so on
panelsSelector(string) is a CSS selector to your panel items and must allowquerySelectorAllto find all panels with role="tabpanel" attribute. These are the items that correspond to your tab button'saria-controlsIDs earlier mentioned:
<div id="panel-1" role="tabpanel" tab-title="Tab 1">
<div>Tab 1 content.</div>
</div>
activeIndex(number) optional index of the initial tab you'd like opened. Defaults to 0.