Table of Contents

$p.gui.tabs (tabbed interface module)

This module provides functionality for simple tabbed interface GUI elements.

Screenshot of a simple tabbed interface.

The tabs

The recommended markup for the tabs is either an <ul>, or an <ol> list, with <a> for the actual tabs. More important, however, is that the attributes are set up as follows:

<ul role="tablist">
  <li role="presentation">
    <a role="tab" href="#panel1" aria-controls="panel1" id="tab1" aria-selected="false">First</a>
  </li>
  <li role="presentation">
    <a role="tab" href="#panel2" aria-controls="panel2" id="tab2" aria-selected="true">Second</a>
  </li>
</ul>

The attributes here have the following meanings:

The panels

As with the tabs, the elements used for the panels can be arbitrarily chosen. In most cases, a block-level element, like <div>, <section> or <article> is probably the best choice.

<div role="tabpanel" id="panel1" aria-labelledby="tab1" hidden></div>
<div role="tabpanel" id="panel2" aria-labelledby="tab2"></div>

These need to be marked up with the following attributes:

Activation

Any structure as the above that is present at the time that the (pre-)initialisation takes place, will automatically be detected and the necessary callback functions will be added.

If a tab interface is dynamically added to the page, it can be activated by calling the following method:

$p.gui.tabs.add(e);

In this case, e must be a reference to the root element (the one with the role=“tablist” attribute)

Notes:
  • This module does not provide any CSS to style the tab interface. When designing the user interface, it is recommended that you use the aria-* and role attributes as selectors.
  • Do not use aria-hidden=“true” for hidden tab panels. This status is already implied by the hidden attribute.

See also

More information