theme.json file is a powerful configuration tool that controls the WordPress Block Editor’s behavior, appearance, and available features. You can use it to define global settings, customize block supports, and create a cohesive design system for your theme.
What is theme.json?
Theme.json is a JSON configuration file that allows you to:- Control which editor features are available to users
- Define global design tokens (colors, typography, spacing)
- Configure block-level settings and styles
- Create a consistent design system across your site
Schema Structure
The theme.json file follows a versioned schema. Here’s the basic structure:Always use
"version": 3 for the latest schema. This ensures you have access to all current features.Settings Configuration
Color Settings
You can define a custom color palette and control color-related features:Typography Settings
Define font families, sizes, and typography controls:Layout Settings
Control the default content width and layout options:Block-Level Settings
You can configure settings for specific blocks using theblocks key:
- Customize Specific Block
- Restrict Block Features
Limiting Editor Features
You can create a highly restricted editing experience by disabling most features:Styles Configuration
Define global and block-specific styles:CSS Custom Properties
Theme.json automatically generates CSS custom properties from your presets:Common Use Cases
Curating the Editor Experience
Restrict editor features while maintaining design consistency:Duotone Configuration
Provide predefined duotone filters:Best Practices
- Start with a minimal configuration: Only define what you need to override
- Use meaningful slug names: Make them descriptive for better developer experience
- Test across blocks: Verify your settings work as expected across different block types
- Document your choices: Add comments (in your theme documentation) explaining why certain features are disabled
- Consider accessibility: Ensure your color combinations meet WCAG contrast requirements
Next Steps
- Learn about Server-side theme.json Filters
- Explore Editor Customization techniques
- Read the theme.json reference documentation