But what does it mean actually? It is a new, very important mechanism introduced in WordPress 5.8. It allows you to control and manage the visual styles of your WordPress website within one simple-to-use file called theme.json.
By creating a
theme.jsonfile in the theme’s top-level directory, themes can configure the existing editor settings (the font sizes preset, whether custom colors are enabled, etc.) as well as the new ones as they are introduced (the duotone preset, whether margin and padding controls are enabled, etc.).
How to use theme.json?
It may seem complicated, but it’s very simple. This file is located in the main directory of your WordPress theme, or child theme. It’s a text file so you don’t need fancy software to edit it and change it to your liking. You will find all the documentation and examples here.
Why theme.json is soooo cool
- In theme.json you can easily overwrite most default settings of a visual layer of your website.
- You can change default colors of different elements, like Gutenberg blocks.
- You can remove / hide some options from Gutenberg blocks settings.
- You can lock some settings so users can not change it while editing website.
- You can disable particular Gutenberg blocks.
- You can change font settings.
- You can enable different hidden features like custom padding, custom margin settings, font family settings, borders, backgrounds etc.
- You can create custom presets with different colors, font sizes, etc
With theme.json you can simply do a lot of cool stuff, and the best thing is that it will be very easy to reuse in different projects. In Astratic Theme, we include a basic theme.json file within the main theme package. We also add a blank theme.json file to the Astratic child theme, so you can play around, use it freely or even overwrite it with your own custom-made theme.json file.