On Monday, July 10, 2023 at 9:23:09 PM UTC-5, luserdroog wrote:
> A <tabs-panel /> accepts contents for two slots, named "tab" and "content". The tabs are shown spaced out and clickable, controlling their associated content.
>
> Critique or comments welcome.
> [...]
You can leverage <details /> for this too. Something like:
<article class="tabs">
<details class="tab">
<summary class="tab-label">Tab 1</summary>
<div class="tab-content">Content 1</div>
</details>
<details class="tab">
<summary class="tab-label">Tab 2</summary>
<div class="tab-content">Content 2</div>
</details>
<details class="tab">
<summary class="tab-label">Tab 3</summary>
<div class="tab-content">Content 3</div>
</details>
</article>
<style>
.tabs {
position: relative;
display: inline-flex;
border: 1px solid blue;
height: 300px;
}
.tab[open] {
background-color: #ccc;
}
.tab-label {
padding: 1em;
border: 1px solid red;
border-radius: 15% 15% 0 0;
}
.tab-content {
position: absolute;
background-color: cyan;
left: 0;
height: calc(100% - 3.1em);
width: 100%;
overflow: auto;
}
</style>
You'll just want to toggle all sibling tabs when one is open by intercepting the 'toggle' event. Here's a quick codepen:
<
https://codepen.io/mlhaufe/pen/abQVrWg>