JSFiddle - React, Tailwind, and code Playground
HTML
<div id="nav"></div>
CSS
#nav {
width: 100px;
height: 100px;
background: blue;
}
#nav.inverted {
background: red;
}
JavaScript
var nav = document.getElementById('nav');
var body = document.body;
body.classList.add('test');
if (body.classList.contains('test')) {
nav.classList.add('inverted')
}