Skip to content

Commit 23a6617

Browse files
committed
Tabs: fix semantic markup
1 parent 4c3f980 commit 23a6617

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

assets/css/site/tabs.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
border-radius: var(--rounded);
55
}
66

7-
.tabs menu {
7+
.tabs nav {
88
display: flex;
99
}
1010

11-
.tabs menu button {
11+
.tabs nav button {
1212
position: relative;
1313
padding: var(--spacing-2) var(--spacing-3);
1414
font-size: var(--text-xs);
1515
overflow: visible;
1616
}
1717

18-
.tabs menu button[aria-current="true"]::after {
18+
.tabs nav button[aria-selected="true"]::after {
1919
position: absolute;
2020
content: "";
2121
height: 2px;
@@ -24,7 +24,7 @@
2424
background: currentColor;
2525
}
2626

27-
.tabs menu button:not([aria-current="true"]):hover {
27+
.tabs nav button:not([aria-selected="true"]):hover {
2828
opacity: 0.75;
2929
}
3030

site/snippets/kirbytext/tabs.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
<menu>
1+
<nav role="tablist">
22
<?php foreach ($tabs as $key => $tab): ?>
33
<button
4-
:aria-current="current === '<?= $key ?>'"
4+
:aria-selected="current === '<?= $key ?>'"
5+
aria-controls="tabs-<?= $id ?>-<?= $key ?>"
6+
id="tabs-<?= $id ?>-<?= $key ?>-label"
7+
role="tab"
58
@click="current = '<?= $key ?>'"
69
>
710
<?= $tab['title'] ?>
811
</button>
912
<?php endforeach ?>
10-
</menu>
13+
</nav>
1114

1215
<?php foreach ($tabs as $key => $tab): ?>
13-
<div v-show="current === '<?= $key ?>'">
16+
<div
17+
v-show="current === '<?= $key ?>'"
18+
aria-labelledby="tabs-<?= $id ?>-<?= $key ?>-label"
19+
id="tabs-<?= $id ?>-<?= $key ?>"
20+
role="tabpanel"
21+
>
1422
<?= $tab['content'] ?>
1523
</div>
1624
<?php endforeach ?>

0 commit comments

Comments
 (0)