Body Toggle

I appreciate the clarity of this trick that Mikael Ainalem posted over on Reddit: It’s a one-liner that toggles the class on the so you can mock up different states and toggle between them on click.

https://css-tricks.com/body-toggle/

Created 4y | Jul 6, 2021, 10:20:56 PM


Login to add comment

Other posts in this group

Make Any File a Template Using This Hidden macOS Tool

Stationery Pad is a handy way to nix a step in your workflow if you regularly use document templates on your Mac. The long-standing Finder feature essentially tells a file’s parent application to o

Feb 10, 2025, 7:20:06 PM | CSS tricks
Organizing Design System Component Patterns With CSS Cascade Layers

I enjoy organizing code and find cascade layers a fantastic way to organize code explicitly as the cascade looks at it. The neat part is, that as much as it helps with "top-level" organization, cas

Feb 10, 2025, 2:40:07 PM | CSS tricks
Container query units: cqi and cqb

A little gem from Kevin Powell's "HTML & CSS Tip of the Week" website, reminding us that using container queries opens up container query units for sizing things based on the size of the queried co

Feb 6, 2025, 3:40:06 PM | CSS tricks
Baseline Status in a WordPress Block

The steps for how I took the Baseline Status web component and made it into a WordPress block that can be used on any page of post.


Feb 5, 2025, 4:30:08 PM | CSS tricks
Compiling CSS With Vite and Lightning CSS

Are partials the only thing keeping you writing CSS in Sass? With a little configuration, it's possible to compile partial CSS files without a Sass dependency. Ryan Trimble has the details.

<hr

Feb 3, 2025, 3:40:18 PM | CSS tricks
Keeping the page interactive while a View Transition is running

When using View Transitions you’ll notice the page becomes unresponsive to clicks while a View Transition is running

Jan 31, 2025, 8:30:06 PM | CSS tricks
Chrome 133 Goodies

Did you see the release notes for Chrome 133? It's currently in beta, but the Chrome team has been publishing a slew of new articles with pretty incredible demos that are tough to ignore. I figured

Jan 31, 2025, 3:50:08 PM | CSS tricks