Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="content">
  <div class="tabWrapper">
    <div class="tabs">
        <div role="tablist" aria-label="tabs">
          <button role="tab" aria-selected="true" id="tab-1">
            Tab 1
          </button>
          <button role="tab" aria-selected="false" id="tab-2">Tab 2
          </button>
          <button role="tab" aria-selected="false" id="tab-3">
            Tab 3
          </button>
        </div>
        <div role="tabpanel" aria-labelledby="tab-1">
          <h3>Tab 1</h3>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla mattis nec nisi tempus scelerisque. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ut nisl ante. Vivamus bibendum erat eu blandit congue. Mauris posuere mi eu enim finibus vestibulum. Nam lectus risus, ultricies quis libero sit amet, congue aliquam nisl. Nullam venenatis eros rhoncus venenatis faucibus. Nulla pellentesque posuere maximus. Nulla odio libero, bibendum a auctor sit amet, luctus ac mi. Praesent ipsum nunc, rhoncus sit amet malesuada quis, sollicitudin ut ante. Maecenas nec risus eleifend, tincidunt metus at, venenatis arcu. Morbi quis hendrerit magna, scelerisque euismod massa. Suspendisse sed auctor lorem. Nunc et eros tortor. Donec scelerisque nibh non dui ullamcorper, sit amet pharetra urna lobortis. Mauris pretium dolor molestie mattis porta.</p>
        </div>
        <div role="tabpanel" aria-labelledby="tab-2" hidden>
          <h3>Tab 2</h3>
          <p>Pellentesque tristique luctus eros vitae pulvinar. Nam eleifend lacus ut odio viverra mattis. Vestibulum sed sapien tellus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed convallis, nibh nec sollicitudin dignissim, tellus tortor iaculis felis, vitae tincidunt augue nibh et erat. Etiam suscipit sapien dolor, quis placerat ex iaculis tincidunt. Nam egestas semper odio, et tempus diam tincidunt eget. Aenean ac purus libero. Etiam egestas tempor lacus vel pretium. Donec in ipsum nec enim commodo pretium. Vivamus ut vulputate magna. Donec ullamcorper justo finibus, efficitur dolor a, dapibus purus. Nam malesuada gravida nisl eget placerat. Aenean diam urna, aliquet a odio ut, luctus condimentum diam. In elementum sagittis elit, sed dapibus velit congue quis. Pellentesque cursus vulputate egestas.</p>
        </div>
        <div role="tabpanel" aria-labelledby="tab-3" hidden>
          <h3>Tab 3</h3>
          <p>Cras in risus sit amet ex auctor imperdiet. Aenean posuere interdum dui sed maximus. Vivamus volutpat rutrum consequat. Aliquam lobortis ornare vehicula. Pellentesque sollicitudin ut lorem ut accumsan. Praesent in justo mattis, mattis ipsum dignissim, consectetur sem. Aliquam blandit ullamcorper maximus. Etiam facilisis ut ex vitae scelerisque. Mauris luctus libero eu diam lobortis, sed posuere ligula imperdiet. Vestibulum sem elit, rutrum vel sollicitudin nec, luctus vitae mi. Proin imperdiet finibus mauris ac eleifend. Aliquam erat volutpat. Sed hendrerit, tortor placerat efficitur pellentesque, risus nisi tincidunt quam, id cursus diam leo non ante. Quisque ac augue tortor. Cras ac felis vel neque ornare mattis a ac tortor.</p>
        </div>
      </div>
  </div>
</div>  
              
            
!

CSS

              
                $lightGrey: #F2F2F2;
$white: #FFFFFF;
$blue: #1849AB;
$black: #000000;

body {
  align-content: center;
  background: $lightGrey;
  display: flex;
  justify-content: center;
  line-height: 2;
  min-height: 100vh;
}
  
.tabs {
  display: grid;
}

[role="tablist"] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  grid-gap: 10px;
}

.tabWrapper {
  display: grid;
  font-family: 'Arial';
  margin-top: 4rem;
  padding: 1rem;
  width: 1000px;
}

[role="tabpanel"] {
  background: $white;
  padding: 2rem;
}

button {
  background: $blue;
  border: 0;
  border-radius: 5px 5px 0 0;
  color: $white;
  cursor:pointer;
  font-size: 1rem;
  height: 40px;
}

button[aria-selected="true"] {
  background: $white;
  color: $black;
}

button:focus {
  box-shadow: 0 0 0 4px rgba(21, 156, 228, 0.7);
  outline: none;
  z-index: 5;
}
              
            
!

JS

              
                const tabs = document.querySelector('.tabs');
const tabButtons = tabs.querySelectorAll('[role="tab"]');
const tabPanels = tabs.querySelectorAll('[role="tabpanel"]');

function handleTabClick(event) {
  tabPanels.forEach(function(panel) {
    panel.hidden = true;
  });

  tabButtons.forEach(function(tab) {
    tab.setAttribute('aria-selected', false);
  });

  event.currentTarget.setAttribute('aria-selected', true);

  const {id} = event.currentTarget;

  const tabPanel = tabs.querySelector(`[aria-labelledby="${id}"]`);
  tabPanel.hidden = false;
}

tabButtons.forEach(button => button.addEventListener('click', handleTabClick));
              
            
!
999px

Console