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

              
                <table>
  <thead>
    <tr>
      <th aria-label="Select"><input type="checkbox" aria-label="Select All" /></th>
      <th scope="col">
        File Name
      </th>
      <th scope="col">
        Type
      </th>
      <th scope="col">
      Size
      </th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><input type="checkbox" aria-label="Images" tabindex="-1"></td>
      <th>
        <button class="file-icon folder" aria-expanded="false" aria-labelledby="r1name r1type r1size">📁</button>
        <span class="fn" id="r1name">Images</span>
      </th>
      <td id="r1type">Folder</td>
      <td id="r1size">
        ---
      </td>
    </tr>
    <tr class="hidden nested level1">
      <td><input type="checkbox" aria-label="IMG008877.jpg" tabindex="-1"></td>
      <th>
        <button class="file-icon" aria-labelledby="r2name r2type r2size">🌆</button>
        <span class="fn" id="r2name">IMG008877.jpg</span>
      </th>
      <td id="r2type">Image</td>
      <td id="r2size">
        1MB
      </td>
    </tr>
    <tr class="hidden nested level1">
      <td><input type="checkbox" aria-label="IMG008899.jpg" tabindex="-1"></td>
      <th>
        <button class="file-icon" aria-labelledby="r008899name r008899type r008899size">🌆</button>
        <span class="fn" id="r008899name">IMG008899.jpg</span>
      </th>
      <td id="r008899type">Image</td>
      <td id="r008899size">
        1.24MB
      </td>
    </tr>
    <tr class="hidden nested level1">
      <td><input type="checkbox" aria-label="IMG008822.jpg" tabindex="-1"></td>
      <th>
        <button class="file-icon" aria-labelledby="r008822name r008822type r008822size">🌆</button>
        <span class="fn" id="r008822name">IMG008822.gif</span>
      </th>
      <td id="r008822type">GIF</td>
      <td id="r008822size">
        750kB
      </td>
    </tr>
    <tr class="hidden nested level1">
      <td><input type="checkbox" aria-label="IMG008844.jpg" tabindex="-1"></td>
      <th>
        <button class="file-icon" aria-labelledby="r008844name r008844type r008844size">🌆</button>
        <span class="fn" id="r008844name">IMG008844.jpg</span>
      </th>
      <td id="r008844type">JPG</td>
      <td id="r008844size">
        1.75MB
      </td>
    </tr>
    <tr>
      <td><input type="checkbox" aria-label="Movies" tabindex="-1"></td>
      <th>
        <button class="file-icon folder" aria-expanded="false" aria-labelledby="r11name r11type r11size">📁</button>
        <span class="fn" id="r11name">Movies</span>
      </th>
      <td id="r11type">Folder</td>
      <td id="r11size">
        ---
      </td>
    </tr>
    <tr class="hidden nested level1">
      <td><input type="checkbox" aria-label="IMG008877.mp4" tabindex="-1"></td>
      <th>
        <button class="file-icon" aria-labelledby="r2name r2type r2size">🌆</button>
        <span class="fn" id="r2name">IMG008877.mp4</span>
      </th>
      <td id="r2type">Video</td>
      <td id="r2size">
        100MB
      </td>
    </tr>
  </tbody>
</table>
              
            
!

CSS

              
                body {
  font-family: sans-serif;
}

table, tr, td, th {
  border-collapse: collapse;
  border: 1px solid black;
  padding: .5rem;
  text-align: left;
}

table {
  width: 30rem;
  margin: 1rem auto;
}

.level1 th {
  padding-left: 1.5rem;
}

tr:focus-within:has(button:focus) {
  border: 2px solid blue;
  background-color: yellow;
}

button {
  background: none;
  padding: none;
  margin: 0 .25rem 0 0;
  border: none;
}
button:focus, button:focus-visible {
  outline:none;
}

input[type="checkbox"] {
  display: block;
  margin: 0 auto;
}

.nested { display:none; }

tr:has(button.folder[aria-expanded="true"]) ~ .nested { display:table-row; }
tr:has(button.folder[aria-expanded="true"]) ~ tr:has(button.folder[aria-expanded="false"]) ~ .nested { display:none; }


              
            
!

JS

              
                document.querySelectorAll('button.folder').forEach(function (element) {   
  element.addEventListener('click', function (e) {
    e.target.ariaExpanded = e.target.ariaExpanded !== 'true';
  });
});

document.querySelectorAll('button.file-icon').forEach(function (element) {   
  element.addEventListener('keyup', function (e) {
  e.stopImmediatePropagation();
  e.preventDefault();
    switch (e.key) {
      case "ArrowRight":
        if (e.target.classList.contains("folder")) {
          e.target.click();
        }
        break;
      case "ArrowLeft":
        if (e.target.classList.contains("folder")) {
          e.target.click();
        }
        break;
      case "ArrowUp":
        prevRowElement = e.target.parentNode.parentNode.previousElementSibling;
        while (!isVisible(prevRowElement) && (prevRowElement !== null)) {
          prevRowElement = prevRowElement.previousElementSibling;
        }
        if (prevRowElement !== null) {
          prevRowElement.querySelector('button.file-icon').focus(); 
        }
        break;
      case "ArrowDown":
        nextRowElement = e.target.parentNode.parentNode.nextElementSibling;
        while (!isVisible(nextRowElement) && (nextRowElement !== null)) {
          nextRowElement = nextRowElement.nextElementSibling;
        }
        if (nextRowElement !== null) {
          nextRowElement.querySelector('button.file-icon').focus(); 
        }
        break;
      case " ":
        e.target.parentNode.parentNode.querySelector('input[type=checkbox]').toggleAttribute('checked'); 
        break;
    }
  });
});

function isVisible(e) {return e && (e.offsetWidth > 0 || e.offsetHeight > 0);}
              
            
!
999px

Console