Menu

Component: Tab

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<div class="tabs-wrapper" id="tabsWrapper">
  <ul role="tablist" class="tabs" arial-label="tabs-description">
    <li>
      <button role="tab" aria-selected="true" aria-controls="tab-1">tab 1</button>
      <div tabindex="0" role="tabpanel" id="tab-1" aria-labelledby="tab-1" tabindex="0">
        ...
      </div>
    </li>
    <li>
      <button role="tab" aria-selected="false" aria-controls="tab-2">tab 2</button>
      <div tabindex="0" role="tabpanel" id="tab-2" aria-labelledby="tab-2" tabindex="0" hidden="">
        ...
      </div>
    </li>
    <li>
      <button role="tab" aria-selected="false" aria-controls="tab-3">tab 3</button>
      <div tabindex="0" role="tabpanel" id="tab-3" aria-labelledby="tab-3" tabindex="0" hidden="">
        ...
      </div>
    </li>
  </ul>
</div>

These tabs are responsive and accessible friendly.
To work well, it requires aria-controls="XX" on button tag which is linked to the next div with id="XX" where XX must be the same value on button and div.

According to W3C, to have an efficient accessibility, tabs require role="tablist", role="tab", role="tabpanel".

  • role="tablist" on ul (container)
  • role="tab" on button (trigger)
  • role="tabpanel" on div (panel)