Tabs

New

Structure

            
<section>
    <h3 id="tablist-1">Tab Title</h3>
    <div class="tab-v2">
        <div class="tab-v2__controls">
            <div class="tab-v2__list" role="tablist" aria-labelledby="tablist-1">
                <button class="tab-v2__btn" id="tab-1" type="button" role="tab" aria-selected="true"
                    aria-controls="tabpanel-1" tabindex="-1">
                    Option 1
                </button>
                <button class="tab-v2__btn" id="tab-2" type="button" role="tab" aria-selected="false"
                    aria-controls="tabpanel-2" tabindex="-1">
                    Option 2
                </button>
            </div>
            <div class="tab-v2__scroll" aria-hidden="true">
                <button tabindex="-1" class="tab-v2__scroll-left"></button>
                <button tabindex="-1" class="tab-v2__scroll-right"></button>
            </div>
        </div>
        <div class="tab-v2__body">
            <div id="tabpanel-1" role="tabpanel" aria-labelledby="tab-1">Content 1</div>
            <div id="tabpanel-2" role="tabpanel" aria-labelledby="tab-2" class="hidden">Content 2</div>
        </div>
    </div>
</section>
            
        

The Tabs  component follows the directives set by W3C and can be referenced at https://www.w3.org/WAI/ARIA/apg/patterns/tabs/examples/tabs-manual/.

 

Guidelines

Pay attention to the accessibility indicators shown in the structure section. Javascript will act to correct certain errors related to attributes, but it is important that they are placed before the code is applied so that the elements have semantic values ​​when the page loads.

 

  • Include aria-selected="true" in the button considered active and aria-selected="false" for the others;
  • Hide the inactive panels using the appropriate class.

Disabling Tabs

For disabling tabs it is just to apply the class tab__btn--disabled to the tab and the Javascript code will recognize the change. Do the opposite to enable a tab again.

Example: 

<button class="tab-v2__btn tab-v2__btn--disabled" id="tab-2" type="button" role="tab" aria-selected="false" aria-controls="tabpanel-2" tabindex="-1">Option 2 </button>

Example - Light Theme

Danish Composers

Maria Theresia Ahlefeldt (16 January 1755 – 20 December 1810) was a Danish, (originally German), composer. She is known as the first female composer in Denmark. Maria Theresia composed music for several ballets, operas, and plays of the royal theatre. She was given good critic as a composer and described as a “ virkelig Tonekunstnerinde ” ('a True Artist of Music').

Example - Dark Theme

Danish Composers

Maria Theresia Ahlefeldt (16 January 1755 – 20 December 1810) was a Danish, (originally German), composer. She is known as the first female composer in Denmark. Maria Theresia composed music for several ballets, operas, and plays of the royal theatre. She was given good critic as a composer and described as a “ virkelig Tonekunstnerinde ” ('a True Artist of Music').