Pen Settings



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


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


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.


Save Automatically?

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.


                <!-- Generic show/hide options -->
<!-- Written as an accordion, but with different CSS also be used for toggling a menu on small screens, or for tooltip-style disclosures -->
<div class="group">
<!-- 1. if you use a link, it must have a href pointing to the panel. Blind users will expect links to go to a new location --> 
<div class="panel-wrapper">
  <a href="#panel1" class="panel-control">Item Title
    <i class="icon-arrow-down" aria-hidden="true"></i><i class="icon-arrow-up" hidden aria-hidden="true"></i>
  <div class="panel-content hidden-all" id="panel1" tabindex="-1">
    <p>Content goes here</p>
<!-- 2. If you use a button, you can use aria-expanded to signal the current state to blind users and leave focus on the button -->
<div class="panel-wrapper">
  <button class="panel-control" type="button" aria-expanded="false">Item Title
    <i class="icon-arrow-down" aria-hidden="true"></i><i class="icon-arrow-up" hidden aria-hidden="true"></i>
  <div class="panel-content hidden-all" id="panel2">
    <p>Oh look it's more content</p>
<!-- Both types must have a visual indicator of the current state. Any accessible icon method is fine. Alternatively, use img elements with appropriate alt text and you can ditch the aria on buttons. I find the aria method easier to integrate with an icon system though. -->



                body {
  font-size: 100%;
  font-family: sans-serif;
.hidden-all {
  display: none;

.panel-wrapper {
  border: 1px solid #cccccc;
  border-radius: 0.25em;
  margin-bottom: 1em; 
  width: 50%;
.panel-control {
  font-size: 1em;
  display: block;
  border: 0;
  padding: 0.5em;
  margin: 0;
  background: inherit;
  width: 100%;
  text-align: left;
  text-decoration: none;
  line-height: 1.2;
  box-sizing: border-box;
.panel-control:focus {
  background: #eeeeee;
  text-decoration: underline;
.panel-control i {
  float: right;
.panel-content {
  padding: 0.5em;
/* Icon font stuff from here on */
@font-face {
  font-family: 'icomoon';
    url('') format('truetype'),
    url('') format('svg');
  font-weight: normal;
  font-style: normal;

i {
  /* use !important to prevent issues with browser extensions that change fonts */
  font-family: 'icomoon' !important;
  speak: none;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1.2;

  /* Better Font Rendering =========== */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
.icon-arrow-up:before {
  content: "\ea41";
.icon-arrow-down:before {
  content: "\ea43";


                const group = document.querySelector('.group')
const toggle1 = group.querySelector("a");
const panel1 = group.querySelector("#panel1");
const toggle2 = group.querySelector('button');
const panel2 = group.querySelector('#panel2')

// events
// Must manage focus on in-page links
toggle1.addEventListener("click", function(e) {
  if (panel1.classList.contains("hidden-all")) {
    updateIcon(this, 'up');
  } else {
    updateIcon(this, 'down');

// Must update ARIA attribute as well as panel for buttons
toggle2.addEventListener("click", function(e) {
  if (panel2.classList.contains("hidden-all")) {
    panel2.setAttribute('aria-expanded', 'true');
    updateIcon(this, 'up')
  } else {
    panel2.setAttribute('aria-expanded', 'false');
    updateIcon(this, 'down')

//utility functions
function updateIcon(whichOne, direction) {
  if (direction === 'up') {
    whichOne.children[0].setAttribute('hidden', 'true');
  } else {
    whichOne.children[1].setAttribute('hidden', 'true');