本文档是 theme.json 版本 1 的规范,适用于 WordPress 5.8 或更高版本。它详细列出了 theme.json 架构中定义的设置和样式属性,为开发者提供配置主题的参考。
This is the specification for version 1 of
theme.json. This version works with WordPress 5.8 or later.
Theme.json version 2 has been released with WordPress 5.9. WordPress will continue to support theme.json version 1. However new features will only be added to [new versions](https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/).
When you are ready to upgrade, see the [theme.json migration guide](https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-migrations/#migrating-from-v1-to-v2) for details on updating to the latest version.
This reference guide lists the settings and style properties defined in the theme.json schema. See the theme.json how to guide for examples and guidance on how to use the theme.json file in your theme.
The last schema for version 1 is available at `https://schemas.wp.org/wp/5.8/theme.json`.
Theme.json schemas for each WordPress version are available at https://schemas.wp.org/wp/{{version}}/theme.json`. For example a schema for WordPress 5.8 is available athttps://schemas.wp.org/wp/5.8/theme.json`.
See Developing with theme.json for how to use the JSON schema in your editor.
Settings related to borders.
| Property | Type | Default | Props |
|---|---|---|---|
| customRadius | boolean | false |
Settings related to colors.
| Property | Type | Default | Props |
|---|---|---|---|
| custom | boolean | true | |
| customDuotone | boolean | true | |
| customGradient | boolean | true | |
| duotone | array | colors, name, slug | |
| gradients | array | gradient, name, slug | |
| link | boolean | false | |
| palette | array | color, name, slug |
Settings related to layout.
| Property | Type | Default | Props |
|---|---|---|---|
| contentSize | string | ||
| wideSize | string |
Settings related to spacing.
| Property | Type | Default | Props |
|---|---|---|---|
| customMargin | boolean | false | |
| customPadding | boolean | false | |
| units | array | px,em,rem,vh,vw,% |
Settings related to typography.
| Property | Type | Default | Props |
|---|---|---|---|
| customFontSize | boolean | true | |
| customLineHeight | boolean | false | |
| dropCap | boolean | true | |
| fontSizes | array | name, size, slug |
Generate custom CSS custom properties of the form --wp--custom--{key}--{nested-key}: {value};. camelCased keys are transformed to kebab-case as to follow the CSS property naming schema. Keys at different depth levels are separated by --, so keys should not include -- in the name.
Border styles.
| Property | Type | Props |
|---|---|---|
| radius | string |
Color styles.
| Property | Type | Props |
|---|---|---|
| background | string | |
| gradient | string | |
| text | string |
Spacing styles.
| Property | Type | Props |
|---|---|---|
| margin | object | bottom, left, right, top |
| padding | object | bottom, left, right, top |
Typography styles.
| Property | Type | Props |
|---|---|---|
| fontSize | string | |
| lineHeight | string |