Tabbed Interface
Purpose
Dynamically stacks multiple sections of content, transforming them into a tabbed interface. Implements the WAI-ARIA tab panel design pattern for large screens and the WAI-ARIA accordion design pattern for small screens.
Working example
How to implement
Tabbed interface
- Add a divelement to the page with the classwb-tabs.
- Add a divelement to the previousdivelement with the classtabpanels.
- For each tab panel, add a detailselement with a uniqueid. Addopen="open"for the tab panel that should be open by default.<div class="wb-tabs"> <div class="tabpanels"> <details id="details-panel1"> ... </details> <details id="details-panel2" open="open"> ... </details>
- Add a summaryelement with the label of the tab to eachdetailselement.<details id="details-panel1"> <summary>Example 1</summary> ... </details> <details id="details-panel2" open="open"> <summary>Example 2</summary> ... </details>
- Add the tab panel content after each summaryelement.
Code
<div class="wb-tabs">
	<div class="tabpanels">
		<details id="details-panel1">
			<summary>Example 1</summary>
			<p>
				...
			</p>
		</details>
		<details id="details-panel2" open="open">
			<summary>Example 2</summary>
			<p>
				...
			</p>
		</details>
		...
	</div>
</div>Carousel
- Add a divelement to the page with the classwb-tabsand either the styling classcarousel-s1orcarousel-s2.
- Add a divelement to the previousdivelement with the classtabpanels.
- For each tab panel, add a divelement with a unique id,role="tabpanel"andclass="out". For the tab panel that should be opened by default, replace theoutclass within.
- Specify the tab panel transition type by adding one of the following classes to the divelement for each of the tab panels:- fade: Fading transition
- slide: Horizontal sliding transition
- slidevert: Vertical sliding transition
 <div class="wb-tabs carousel-s1"> <div class="tabpanels"> <div role="tabpanel" id="panel1" class="in fade"> </div> <div role="tabpanel" id="panel2" class="out fade"> </div> </div> </div>
- Add a figureelement to each tab panel.
- Add content to each figureelement:- Image: Add an image to the figureelement followed by afigcaptionelement with the caption for the tab panel.<div role="tabpanel" id="panel1" class="in fade"> <figure> <img src="img/protect-environment.jpg" alt="Panel 1" /> <figcaption> <p> Take Note: <a href="http://www.tc.gc.ca/eng/civilaviation/opssvs/general-personnel-changes-1814.htm">Renewal of the Aviation Document Booklet</a> <br /> Learn more about <a href="http://www.tc.gc.ca/eng/air-menu.htm">air transportation</a> in Canada. </p> </figcaption> </figure> </div>
- Video: Add a multimedia player to the figureelement according to the multimedia player documentation.<div role="tabpanel" id="panel1" class="in fade"> <figure class="wb-mltmd"> <video poster="../multimedia/demo/video1-en.jpg" title="Looking for a Job"> <source type="video/webm" src="http://video2.servicecanada.gc.ca/video/boew-wet/te-lj-eng.webm" /> <source type="video/mp4" src="http://video2.servicecanada.gc.ca/video/boew-wet/te-lj-eng.mp4" /> <track src="../multimedia/cpts-lg-en.html" kind="captions" data-type="text/html" srclang="en" label="English" /> </video> <figcaption> <p>Looking for a Job (<a href="../multimedia/cpts-lg-en.html">Transcript</a>)</p> </figcaption> </figure> </div>
- Other content: Add content to the figureelement followed by afigcaptionelement with the caption for the tab panel.<div role="tabpanel" id="panel1" class="in fade"> <figure> <table> ... </table> <figcaption> <p>Tab panel caption</p> </figcaption> </figure> </div>
 
- Image: Add an image to the 
- Add a ulelement withrole="tablist"at the start of thedivelement with thewb-tabsclass.
- For each tab panel, add an lielement to the previousulelement. Addclass="active"for the tab panel that should be open by default.
- Add an aelement to eachlielement
- Add to each lielement anaelement with the label of the tab and that links to the associated tab panel.<ul role="tablist"> <li class="active"><a href="#panel27">Tab 1</a></li> <li><a href="#panel28">Tab 2</a></li> ... </ul>
- Optional: Override the default settings using the configuration options.
- Optional: Add an external link that affects which tab is visible. The href attribute includes the id of the panel to make visible. (v4.0.8+)
<p><a href="#panel3" class="wb-tabs-ext">Show the third panel</a></p>
Code
<div class="wb-tabs carousel-s1">
	<ul role="tablist">
		<li class="active"><a href="#panel1">Tab 1</a></li>
		<li><a href="#panel2">Tab 2</a></li>
		...
	</ul>
	<div class="tabpanels">
		<div role="tabpanel" id="panel1" class="in fade">
			<figure>
				<img src="img/protect-environment.jpg" alt="Panel 1" />
				<figcaption>
					<p>
						...
					</p>
				</figcaption>
			</figure>
		</div>
		<div role="tabpanel" id="panel2" class="out fade">
			<figure>
				<img src="img/banff.jpg" alt="Panel 2" />
				<figcaption>
					<p>
						...
					</p>
				</figcaption>
			</figure>
		</div>
		...
	</div>
</div>Configuration options - Tabbed interface and carousel
| Option | Description | How to configure | Values | 
|---|---|---|---|
| Update the URL hash ( data-wb-tabs) (v4.0.9+) | Configure the tab interface or carousel to update the URL hash every time the tab panel changes through the updateHashproperty of thedata-wb-tabsattribute. | Add the data-wb-tabsattribute to the element withclass="wb-tabs"and include theupdateHashproperty with a true or false value. | 
 | 
| Update the URL hash ( update-hash) (v4.0.9+) | Configure the tab interface or carousel to update the URL hash every time the tab panel changes through the update-hashclass. | Add update-hashafter thewb-tabsclass. | 
 | 
| Ignore session storage ( data-wb-tabs) (v4.0.12+) | Configure the tab interface to remain on the first or default selected tab on all page loads through the ignoreSessionproperty of thedata-wb-tabsattribute. | Add the data-wb-tabsattribute to the element withclass="wb-tabs"and include theignoreSessionproperty with a true or false value. | 
 | 
| Ignore session storage ( ignore-session) (v4.0.12+) | Configure the tab interface to remain on the first or default selected tab on all page loads through the ignore-sessionclass. | Add ignore-sessionafter thewb-tabsclass. | 
 | 
| Print only the active (visible) panel ( print-active) (v4.0.15+) | Configure the tab interface to print only the active (visible) panel through the print-activeclass. | Add print-activeafter thewb-tabsclass. | 
 | 
Configuration options - Carousel only
| Option | Description | How to configure | Values | 
|---|---|---|---|
| Carousel style | Configures the carousel style. | Add the value after the wb-tabsclass (e.g.,class="wb-tabs carousel-s1") | 
 | 
| Change rotation speed ( data-wb-tabs) | Configure the tab rotation speed through the intervalproperty of thedata-wb-tabsattribute. | Add the data-wb-tabsattribute to the element withclass="wb-tabs"and include theintervalproperty with the number of seconds between tab rotations. | 
 | 
| Change rotation speed ( slow,fast) | Configure the tab rotation speed through either the sloworfastclasses. | Add either sloworfastafter thewb-tabsclass. | 
 | 
| Tab panel transitions | Configure the tab panel transition type through the fade,slideorslidevertclasses. | Add fade,slideorslidevertafter theinoroutclass on each tab panel. | 
 | 
| Exclude play ( data-wb-tabs) (v4.0.5+) | Exclude the play button from the carousel controls through the excludePlayproperty of thedata-wb-tabsattribute. | Add the data-wb-tabsattribute to the element withclass="wb-tabs"and include theexcludePlayproperty withtruefor the value. | 
 | 
| Exclude play ( exclude-play) (v4.0.5+) | Exclude the play button from the carousel controls through the exclude-playclass. | Add exclude-playafter thewb-tabsclass. | 
 | 
| Play on page load ( data-wb-tabs) (v4.0.5+) | Play the carousel on page load through the playingproperty of thedata-wb-tabsattribute.Warning: Playing on page load can be distracting and cause usability issues for some users. Note: Playing will be disabled if the play button is excluded from the carousel controls. | Add the data-wb-tabsattribute to the element withclass="wb-tabs"and include theplayingproperty withtruefor the value. | 
 | 
| Play on page load ( playing) | Play the carousel on page load through the playingclass.Warning: Playing on page load can be distracting and cause usability issues for some users. Note: Playing will be disabled if the play button is excluded from the carousel controls. | Add playingafter thewb-tabsclass. | 
 | 
Events
| Event | Trigger | What it does | 
|---|---|---|
| wb-init.wb-tabs | Triggered manually (e.g., $( ".wb-tabs" ).trigger( "wb-init.wb-tabs" );). | Used to manually initialize the Tabbed interface plugin. Note: The Tabbed interface plugin will be initialized automatically unless the required markup is added after the page has already loaded. | 
| wb-ready.wb-tabs(v4.0.5+) | Triggered automatically after a tabbed interface or carousel initializes. | Used to identify which tabbed interface or carousel was initialized (target of the event)  | 
| wb-updated.wb-tabs(v4.0.5+) | Triggered automatically after a tabbed interface/carousel was updated (visible tab panel changed). | Used to identify which tabbed inteface/carousel was updated (target of the event) and to pass along the newly visible panel (as a jQuery object).  | 
| wb-shift.wb-tabs | Triggered manually or automatically to change which tab panel is visible. | Changes which tab panel is visible. The value of shifttois the number of tab panels to move forwards (positive number) or backwards (negative number). | 
| wb-select.wb-tabs(v4.0.8+) | Triggered manually or automatically to change which tab panel is visible. | Changes which tab panel is visible. The value of idis the id attribute of the tab panel to make visible. | 
| wb-ready.wb(v4.0.5+) | Triggered automatically when WET has finished loading and executing. | Used to identify when all WET plugins and polyfills have finished loading and executing.  | 
Source code
Report a problem on this page
- Date modified: