<script type="module" src="https://spicy-sections.glitch.me/SpicySections-2.js"></script>

<header>
  <h1>&lt;spicy-sections&gt;*</h1>
  <p>(*official name pending)</p>
</header>

<spicy-sections>
<h2>Section 1</h2>
<div>
  <p>
    This is some text underneath Heading Two.
  </p>
  <h3>Another heading level deep we go</h3>
  <p>
    In a tab state, we likely want to style:
  </p>
  <ul>
    <li>The outer box</li>
    <li>The tab bar</li>
    <li>The tabs themselves</li>
    <li>The selected tab</li>
    <li>The tab panel area</li>
  </ul>
</div>
<h2>Section 2</h2>
<div>
  <p>
    Content for panel 2 goes here
  </p>
</div>
<h2>Section 3</h2>
<ul>
  <li>one</li>
  <li>two</li>
  <li>three</li>
  <li>four</li>
  <li>five</li>
  <li>six</li>
  <li>seven</li>
</ul>
<h3>Section 3</h3>
<p>And Another one</p>
</spicy-sections>
/* BORING STUFF */
body {
  padding: 2rem;
  
}

header {
  background: red;
  color: white;
  text-align: center;
  padding: 1rem;
  margin-block: 4vw;
  transform: rotate(-2deg);
  font-family: ui-mono, monospace;
  
  h1 {
    line-height: 1;
    font-size: clamp(1.2rem, 7vw, 3rem);
  }
  p{
    margin: 0;
  }
}

/* SPICY SECTIONS STUFF */

spicy-sections {
  /* NOT FINAL SYNTAX  */
  --bg: rgba(255,0,0,0.1);
  --const-mq-affordances: [screen and (max-width: 40em)] collapse | [screen and (min-width: 50em) ] tab-bar;
  display: block;
  background: var(--bg)
}

spicy-sections h2, 
spicy-sections h3 {
  --heading-size: 1rem;
  margin: 0;
  padding: 0.5rem;
  line-height: 1;
  font-weight: 600;
  font-size: var(--heading-size);
    
}

spicy-sections[affordance="tab-bar"] h2,
spicy-sections[affordance="tab-bar"] h3 {
  border: 1px solid #ccc;
  border-bottom: 0;
  margin-inline: 0.5rem;
}

spicy-sections [aria-selected="true"] {
  background: red;
}

spicy-sections::part(tab-list) {
  background: orange;
}

spicy-sections[affordance="collapse"] {
  --bg: rgba(0, 255,0,0.1);
}

spicy-sections[affordance="tab-bar"] {
  --bg: rgba(0, 0, 255,0.1);
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.