The theme.json file is the control centre of a block theme. It declares which design options the editor offers and what the default look of every block is. Used well, it replaces a surprising amount of custom CSS and keeps a design system consistent. Used carelessly, it becomes a long file nobody dares to edit. This article covers the practical parts.
Settings versus styles
Two top-level sections do most of the work. Settings define what is available: the colour palette, the font sizes, the spacing scale, the content width, and which controls appear in the editor. Styles define how things look by default: the page background, link colour, heading sizes, button appearance. A helpful rule of thumb is that settings are the vocabulary and styles are the sentences written with it.
A small example
The following file defines a three-colour palette, a spacing scale, two font sizes and some global styles. The schema line enables validation and autocomplete in many code editors.
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 3,
"settings": {
"color": {
"palette": [
{ "slug": "base", "name": "Base", "color": "#ffffff" },
{ "slug": "contrast", "name": "Contrast", "color": "#111111" },
{ "slug": "accent", "name": "Accent", "color": "#0b5cad" }
]
},
"spacing": {
"spacingSizes": [
{ "slug": "small", "name": "Small", "size": "1rem" },
{ "slug": "medium", "name": "Medium", "size": "2rem" },
{ "slug": "large", "name": "Large", "size": "4rem" }
]
},
"typography": {
"fontSizes": [
{ "slug": "body", "name": "Body", "size": "1.125rem" },
{ "slug": "large", "name": "Large", "size": "clamp(1.5rem, 1.2rem + 1vw, 2rem)" }
]
}
},
"styles": {
"color": { "background": "var(--wp--preset--color--base)", "text": "var(--wp--preset--color--contrast)" },
"elements": {
"link": { "color": { "text": "var(--wp--preset--color--accent)" } }
}
}
}
Every preset becomes a CSS custom property following the pattern --wp--preset--color--accent, which you can use in your own stylesheets too. That is the real payoff: one definition feeds the editor controls, the block output and any extra CSS.
Where styles can be set
- Global – the top level of
styles, applying to the whole site. - Elements – links, headings, buttons and similar, across all blocks.
- Blocks – defaults for a specific block such as
core/quote. - Variations – optional style variation files in a
stylesfolder, which offer alternative palettes or type choices without a second theme.
Practical advice
Keep palettes small. Every colour you add is one more choice for editors to get wrong. Name colours by role (base, contrast, accent) rather than appearance, so a later rebrand does not leave a colour called “Blue” that is actually orange.
Use fluid sizes sparingly. The clamp() function lets type scale between viewport widths, which works well for headings. Check the result at both extremes before settling on values, and make sure body text stays comfortable to read.
Lock down what you do not want changed. You can disable custom colours, gradients or font sizes so editors choose only from your presets. That is often the right call for brand-sensitive sites, but be deliberate: too many restrictions frustrate the people the system is meant to help.
Mind the layering. Values saved by users in the Site Editor override the theme file. When something looks different from what theme.json says, check the editor’s user customisations before debugging code.
Keep the file maintainable
Validate against the schema, commit changes in small steps and test visually on a staging site. The reference on developer.wordpress.org lists every available property, and the schema changes as WordPress evolves, so treat the documentation as the authority for the version you run.