Write WordPress theme configuration in PHP, then generate theme.json and style
variation JSON files during development or your build. WordPress uses the generated
files; it does not need to run this generator on production requests.
These pages describe the current repository API. When using a published version, check that its commands and methods match the examples. The package is experimental; review changes before upgrading.
The examples follow a small theme with a primary color, a body font size, and
a dark variation. Each chapter explains which file to edit. Commands use
vendor/bin/theme-json from the theme root; global installations use theme-json.
| Chapter | What you will learn |
|---|---|
| Entrypoints and ThemeJson | Return a callable, set metadata, and use generic paths |
| Settings | Configure editor controls, layout, spacing, and custom values |
| Presets and references | Register reusable values and use them in styles |
| Typography and fonts | Font families, font files, font sizes, and fluid typography |
| Styles and scopes | Global styles, blocks, elements, states, and block style variations |
| Templates and patterns | Register template metadata and Pattern Directory slugs |
- CLI commands and options
- API overview and root methods
- Settings API
- Styles API
- Preset and utility API
- Troubleshooting
- Migration from older versions
For work on the generator itself, see Contributing.