这是 version 1 的
theme.json规范。此版本适用于 WordPress 5.8 或更高版本。
Theme.json version 2 已随 WordPress 5.9 发布。WordPress 将继续支持 theme.json version 1。但是,新功能将仅添加到 [new versions](https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/) 中。
当您准备升级时,请参阅 [theme.json migration guide](https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-migrations/#migrating-from-v1-to-v2) 以获取升级到最新版本的详细信息。
本参考指南列出了在 theme.json schema 中定义的设置和样式属性。有关如何在主题中使用 theme.json 文件的示例和指导,请参阅 theme.json how to guide。
JSON Schema
Version 1 的最新 schema 可在 `https://schemas.wp.org/wp/5.8/theme.json` 获取。
每个 WordPress 版本的 Theme.json schemas 可在 https://schemas.wp.org/wp/{{version}}/theme.json` 获取。例如,WordPress 5.8 的 schema 可在https://schemas.wp.org/wp/5.8/theme.json` 获取。
有关如何在编辑器中使用 JSON schema,请参阅 Developing with theme.json。
Settings
border
与边框相关的设置。
| Property | Type | Default | Props |
|---|---|---|---|
| customRadius | boolean | false |
color
与颜色相关的设置。
| 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 |
layout
与布局相关的设置。
| Property | Type | Default | Props |
|---|---|---|---|
| contentSize | string | ||
| wideSize | string |
spacing
与间距相关的设置。
| Property | Type | Default | Props |
|---|---|---|---|
| customMargin | boolean | false | |
| customPadding | boolean | false | |
| units | array | px,em,rem,vh,vw,% |
typography
与排版相关的设置。
| Property | Type | Default | Props |
|---|---|---|---|
| customFontSize | boolean | true | |
| customLineHeight | boolean | false | |
| dropCap | boolean | true | |
| fontSizes | array | name, size, slug |
custom
生成形式为 --wp--custom--{key}--{nested-key}: {value}; 的自定义 CSS custom properties。遵循 CSS 属性命名 schema,camelCased 键将转换为 kebab-case。不同深度级别的键由 -- 分隔,因此键名中不应包含 --。
Styles
border
边框样式。
| Property | Type | Props |
|---|---|---|
| radius | string |
color
颜色样式。
| Property | Type | Props |
|---|---|---|
| background | string | |
| gradient | string | |
| text | string |
spacing
间距样式。
| Property | Type | Props |
|---|---|---|
| margin | object | bottom, left, right, top |
| padding | object | bottom, left, right, top |
typography
排版样式。
| Property | Type | Props |
|---|---|---|
| fontSize | string | |
| lineHeight | string |