JSFiddle - React, Tailwind, and code Playground

by Flexmonster Pivot Table

HTML

<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<button onclick="setTheme('https://cdn.flexmonster.com/flexmonster.min.css')">Light theme</button>
<button onclick="setTheme('https://cdn.flexmonster.com/theme/midnight/flexmonster.min.css')">Dark theme</button>

<div id="pivot-container"></div>

CSS

.demo-toolbar {
  padding: 7px;
}

.demo-toolbar .theme-name {
  margin-right: 7px;
  text-transform: none;
  display: none;
  color: #fff;
}

.demo-toolbar .btn-theme {
  width: 60px;
  margin: 7px 7px 7px 0px;
  border-radius: 5px;
  vertical-align: middle;
  padding: 7px;
  background-color: #F5F5F5;
  border: none;
  white-space: nowrap;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-block;
  font-weight: normal;
  font-size: 14px;
  text-align: center;
  align-items: flex-start;
  box-sizing: border-box;
}

.demo-toolbar .btn-theme:hover {
  border: none;
}

.demo-toolbar .btn-theme.btn-active {
  width: 150px;
  position: relative;
}

.demo-toolbar .btn-theme.btn-active::after {
  content: '';
  position: absolute;
  top: 100%;
  left: calc(50% - 7px);
  width: 15px;
  height: 7px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.demo-toolbar .btn-theme.btn-active .theme-name {
  display: inline-block;
}

.demo-toolbar .btn-theme .theme-name-short {
  color: #fff;
  display: inline-block;
  padding: 7px;
  border-radius: 5px;
}

.demo-toolbar .striped-lightblue .theme-name-short,
.demo-toolbar .striped-lightblue:hover,
.demo-toolbar .striped-lightblue.btn-active,
.demo-toolbar .striped-lightblue.btn-active::after {
  background: #0288D1;
}

.demo-toolbar .bright-orange .theme-name-short,
.demo-toolbar .bright-orange:hover,
.demo-toolbar .bright-orange.btn-active,
.demo-toolbar .bright-orange.btn-active::after {
  background: #FB7841;
}

.demo-toolbar .yellow .theme-name-short,
.demo-toolbar .yellow:hover,
.demo-toolbar .yellow.btn-active,
.demo-toolbar .yellow.btn-active::after {
  background: #FBC02D;
}

.demo-toolbar .green .theme-name-short,
.demo-toolbar .green:hover,
.demo-toolbar .green.btn-active,
.demo-toolbar .green.btn-active::after {
  background: #69b01e;
}

.demo-toolbar .striped-teal .theme-name-short,
.demo-toolbar .striped-teal:hover,
.demo-toolbar .striped-teal.btn-active,
.demo-toolbar .striped-teal.btn-active::after {
 ...

JavaScript

function setTheme(cssUrl) {
  var prevThemeTags = getPrevTheme();
  var link = document.createElement('link');
  link.href = cssUrl;
  link.rel = "stylesheet";
  link.type = "text/css";
  link.onload = function() {
    if (prevThemeTags != null) {
      for (var i = 0; i < prevThemeTags.length; i++) {
        if (window.ActiveXObject || "ActiveXObject" in window) {
          prevThemeTags[i].removeNode(true);
        } else {
          prevThemeTags[i].remove();
        }
      }
    }
  };
  document.body.appendChild(link);
}

function getPrevTheme() {
  var linkTags = document.head.getElementsByTagName("link");
  var prevThemeTags = [];
  for (var i = 0; i < linkTags.length; i++) {
    if (linkTags[i].href.indexOf("flexmonster.min.css") > -1 || linkTags[i].href.indexOf("flexmonster.css") > -1) {
      prevThemeTags.push(linkTags[i]);
    }
  }
  linkTags = document.body.getElementsByTagName("link");
  for (var i = 0; i < linkTags.length; i++) {
    if (linkTags[i].href.indexOf("flexmonster.min.css") > -1 || linkTags[i].href.indexOf("flexmonster.css") > -1) {
      prevThemeTags.push(linkTags[i]);
    }
  }
  return prevThemeTags;
}

var pivot = new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  report: {
    dataSource: {
      filename: "data/sales.csv"
    },
    "slice": {
      "rows": [{
        "uniqueName": "Salesperson"
      }],
      "columns": [{
          "uniqueName": "Month",
          "filter": {
            "members": [
              "month.[june]",
              "month.[july]",
              "month.[august]"
            ]
          }
        },
        {
          "uniqueName": "[Measures]"
        }
      ],
      "measures": [{
        "uniqueName": "Revenue",
        "aggregation": "sum"
      }],
      "sorting": {
        "column": {
          "type": "desc",
          "tuple": [],
          "measure": "Revenue"
        }
      }
    },
    "formats": [{
      "name": "",
     ...