CSS Trick: Toggle Body Classes for Rapid State Mockups
Mikael Ainalem shared a clever Reddit tip that boils down to a single line of JavaScript. It toggles a class on the <body> element, letting you flip between different design states with a click — perfect for quick mockups. The same approach works on any element, not just the body.
<body onclick="this.classList.toggle("active");">
This is a surprisingly powerful pattern. As “The Power of Changing Classes” points out, swapping classes can unlock major UI flexibility. Even if JavaScript isn’t your strong suit, classList is the one API worth remembering.



