I completely get the purpose right here: make CSS extra modular and scalable in WordPress. Put all of your world WordPress theme types in a single file, together with variations. JSON presents a properly structured syntax that’s simply consumable by JavaScript, thereby permitting the candy affordance of loading precisely what we wish when we wish it.
The issue, to me, is that writing “CSS” in a theme.json
file is a whole psychological mannequin switcher-oo. Slightly than selectors, we’ve an entire set of objects we’ve to learn about simply to pick one thing. We’ve JSON properties that appear and feel like CSS properties, solely they need to be camelCased
being JavaScript and all. And we’re configuring options in the course of the types, which means we’ve misplaced a transparent separation of issues.
I’m enjoying satan’s advocate, after all. There’s plenty of upside to abstracting CSS with JSON for the very area of interest function of theming CMS templates and elements. However after a decade of “CSS-in-JS is the Approach™” I’m much less inclined to purchase into it. CSS is the bee’s knees simply the way in which it’s and I’m OK counting on it solely, whether or not it’s within the required fashion.css
file or another plain ol’ CSS file I generate. However that additionally means I’m dropping out on the WordPress options that require you to put in writing types in a theme.json
file, like fashion variations that may be toggled instantly within the WordPress admin.
No matter all that, I’m linking this up as a result of Justin does bang-up work (no shock, actually) explaining and illustrating the methods of CSS-in-WordPress. We’ve a whole information that Ganesh rocked a few years in the past. You may test that to get aware of some terminology, leap right into a nerdy deep dive on how WordPress generates lessons from JSON, or simply use the reference tables as a cheat sheet.