Responsive tab system built with flexbox
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore functional concept Jun 7, 2016
LICENSE Initial commit Jun 5, 2016 readme example HTML fix Aug 1, 2016
flextabs.css rename css and js files Jun 10, 2016
flextabs.js add aria-expanded support Feb 4, 2018
index.html update examples Jun 13, 2016
package-lock.json update bsync Jan 17, 2019
package.json update bsync Jan 17, 2019


Responsive tab system built with flexbox

Examples available at


  • CSS media queries control multi (accordion) and single (tabs) toggle views
  • Minimal styling makes it easy to integrate into any design
  • Dependency free (no jQuery)
  • Lightweight at under 2k for both CSS and JavaScript before minification and gzip
  • Works in modern browsers that support flexbox (IE 10+)
  • Keyboard accessible
  • Logical structuring when CSS and JavaScript are disabled



Include flextabs CSS:

<link href="flextabs.css" rel="stylesheet">

Include flextabs JavaScript:

<script src="flextabs.js"></script>

Call flextabs on your container elements:

var targets = document.querySelectorAll('.flextabs');
for (var i = 0; i < targets.length; i += 1) {
  var tabs = flextabs(targets[i]);


You can also install flextabs using npm:

npm install flextabs --save

UMD is used to support both AMD and CommonJS environments. For example, with Browserify you could use var flextabs = require('flextabs'); at the top of the above script block.



In this example flextabs is used as the container class, but it can be set to whatever selector is called through your JavaScript. The only restriction in element ordering is that pairs of flextabs__toggle and flextabs__content should always both appear before another pair.

<div class="flextabs">
  <h3 class="flextabs__tab">
    <button class="flextabs__toggle">Toggle</button>
  <div class="flextabs__content">
    <p>Tab 1 content</p>
  <h3 class="flextabs__tab">
    <button class="flextabs__toggle">Toggle</button>
  <div class="flextabs__content">
    <p>Tab 2 content</p>
  <h3 class="flextabs__tab">
    <button class="flextabs__toggle">Toggle</button>
  <div class="flextabs__content">
    <p>Tab 3 content</p>


The following shows how you can switch from multi (accordion) to single (tabs) toggle view using media queries.

@media (min-width: 64em) {
  .flextabs__tab {
    /* shift all tabs to appear before content */
    order: -1;
    /* let tabs scale to fit multiple on each row */
    width: auto;
  .flextabs__content--active {
    /* ignore states activated for multi (accordion) toggle view */
    display: none;
  .flextabs__content--active--last {
    /* show the last activated item */
    display: block;




The element that serves as the individual tab container. Can be combined with flextabs__toggle.


The element that is clicked to activate a tab. Can be combined with flextabs__tab.


Container for the tab content that will be shown and hidden.


flextabs__toggle--active, flextabs__content--active

Determines the active items for multi (accordion) toggle view. Individual item state will be toggled with each trigger, so more than one instance of this class can occur at a time. Multiple can be added directly to the HTML to set active items for initial page load.

flextabs__toggle--active--last, flextabs__content--active--last

Classes that will be active on the last activated item and removed from all others. This is used for the single (tabs) toggle view as only one item is active at a time. One pair can be added directly to the HTML to set the active item for initial page load.