The tabs component allows users to switch between two or more related sections of content on the same web page, displaying one section at a time.
Use the tabs component when:
Do not use the tabs component when a page reload is triggered. In this case, use the display switcher component instead.
Furthermore, do not use a tabs component:
Alternatives to using a tabs component:
For full documentation of the used javaScript library, see allieTabs
<div class="tabs {{ modifier }}" data-tabs>
<ul role="tablist">
{% for tab in tabs %}
<li role="presentation">
<a role="tab" href="#{{ modifier ~ tab.target }}" aria-controls="{{ modifier ~ tab.target }}">
{{ tab.label }}
</a>
</li>
{% endfor %}
</ul>
{% for tab in tabs %}
<div role="tabpanel" id="{{ modifier ~ tab.target }}">
{{ tab.content }}
</div>
{% endfor %}
</div>
<!-- Dark -->
<div class="tabs dark" data-tabs>
<ul role="tablist">
<li role="presentation">
<a role="tab" href="#darktab1" aria-controls="darktab1">
tab 1
</a>
</li>
<li role="presentation">
<a role="tab" href="#darktab2" aria-controls="darktab2">
tab 2
</a>
</li>
<li role="presentation">
<a role="tab" href="#darktab3" aria-controls="darktab3">
tab 3
</a>
</li>
</ul>
<div role="tabpanel" id="darktab1">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>
</div>
<div role="tabpanel" id="darktab2">
<ul>
<li>Lorem ipsum dolor sit amet.</li>
<li>Expedita illo mollitia tempore temporibus.</li>
<li>Explicabo harum nam nobis sequi.</li>
<li>Ab ea earum impedit optio.</li>
<li>Dolorem ipsa libero nobis repellendus.</li>
</ul>
</div>
<div role="tabpanel" id="darktab3">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>
</div>
</div>
<!-- Light -->
<div class="tabs light" data-tabs>
<ul role="tablist">
<li role="presentation">
<a role="tab" href="#lighttab1" aria-controls="lighttab1">
tab 1
</a>
</li>
<li role="presentation">
<a role="tab" href="#lighttab2" aria-controls="lighttab2">
tab 2
</a>
</li>
<li role="presentation">
<a role="tab" href="#lighttab3" aria-controls="lighttab3">
tab 3
</a>
</li>
</ul>
<div role="tabpanel" id="lighttab1">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>
</div>
<div role="tabpanel" id="lighttab2">
<ul>
<li>Lorem ipsum dolor sit amet.</li>
<li>Expedita illo mollitia tempore temporibus.</li>
<li>Explicabo harum nam nobis sequi.</li>
<li>Ab ea earum impedit optio.</li>
<li>Dolorem ipsa libero nobis repellendus.</li>
</ul>
</div>
<div role="tabpanel" id="lighttab3">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>
</div>
</div>
/* Dark */
{
"modifier": "dark",
"tabs": [
{
"label": "tab 1",
"target": "tab1",
"content": "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>"
},
{
"label": "tab 2",
"target": "tab2",
"content": "<ul>\n<li>Lorem ipsum dolor sit amet.</li>\n<li>Expedita illo mollitia tempore temporibus.</li>\n<li>Explicabo harum nam nobis sequi.</li>\n<li>Ab ea earum impedit optio.</li>\n<li>Dolorem ipsa libero nobis repellendus.</li>\n</ul>"
},
{
"label": "tab 3",
"target": "tab3",
"content": "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>"
}
]
}
/* Light */
{
"modifier": "light",
"tabs": [
{
"label": "tab 1",
"target": "tab1",
"content": "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>"
},
{
"label": "tab 2",
"target": "tab2",
"content": "<ul>\n<li>Lorem ipsum dolor sit amet.</li>\n<li>Expedita illo mollitia tempore temporibus.</li>\n<li>Explicabo harum nam nobis sequi.</li>\n<li>Ab ea earum impedit optio.</li>\n<li>Dolorem ipsa libero nobis repellendus.</li>\n</ul>"
},
{
"label": "tab 3",
"target": "tab3",
"content": "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae distinctio dolore in, odio odit sapiente. Accusamus hic illum quaerat repellendus!</p>"
}
]
}
.tabs {
[role='tabpanel'] {
@include theme('background-color', 'color-secondary-pastel', 'tab-background-color');
padding: 20px 20px 10px;
&:target {
display: block;
}
&[aria-hidden] {
&[aria-hidden='true'] {
display: none;
}
&[aria-hidden='false'] {
display: block;
}
}
}
[role='tablist'] {
display: flex;
flex-direction: column;
margin: 0;
list-style: none;
@include desktop {
flex-direction: row;
}
> li[role='presentation'] {
flex: 0 0 auto;
margin: 0;
a,
a[href^="mailto:"],
a[download],
a[href^="http://"]:not([href*="gent.be"]),
a[href^="https://"]:not([href*="gent.be"]) {
@include reset-link-background;
@include theme('color', 'color-tertiary', 'default-text-color');
display: inline-block;
width: 100%;
padding: 20px;
font-weight: 600;
line-height: 128%;
text-align: center;
text-decoration: none;
@include desktop {
width: auto;
font-size: 1rem;
line-height: 130%;
text-align: left;
}
&::after {
@include theme('color', 'color-zero');
display: block;
bottom: 0;
left: 0;
width: 0;
margin: 0 auto;
transition: width 100ms;
border-bottom: 3px solid;
content: '';
overflow: visible;
}
&[role='tab'][aria-selected='true'],
&:hover,
&:focus {
background: transparent;
&::after {
width: 100%;
}
}
}
[role='tab'][aria-selected='true'] {
@include theme('background-color', 'color-secondary-pastel', 'tab-background-color');
border-bottom: 0;
}
}
}
&.light {
[role='tabpanel'] {
background-color: transparent;
}
[role='tablist'] {
@include theme('border-color', 'color-secondary-pastel', 'tab-background-color');
}
}
}