Gutenberg 区块编辑器文档

title: "Theme.json 版本 1 参考" post_status: publish comment_status: open taxonomy: category: - gutenberg-docs post_tag: - Theme Json Reference - Reference Guides - Repos


Theme.json 版本 1 参考

这是 theme.json 版本 1 的规范。此版本适用于 WordPress 5.8 或更高版本。

Theme.json 版本 2 已随 WordPress 5.9 发布。WordPress 将继续支持 theme.json 版本 1。但新功能将仅添加到[新版本](/docs/reference-guides/theme-json-reference/theme-json-living)。 当您准备升级时,请参阅 [theme.json 迁移指南](/docs/reference-guides/theme-json-reference/theme-json-migrations#migrating-from-v1-to-v2) 了解更新到最新版本的详细信息。

本参考指南列出了 theme.json 架构中定义的设置和样式属性。有关如何在主题中使用 theme.json 文件的示例和指导,请参阅 theme.json 使用指南

JSON 架构

版本 1 的最新架构位于 https://schemas.wp.org/wp/5.8/theme.json

每个 WordPress 版本的 theme.json 架构均可在 https://schemas.wp.org/wp/{{version}}/theme.json 获取。例如,WordPress 5.8 的架构位于 https://schemas.wp.org/wp/5.8/theme.json

关于如何在编辑器中应用此 JSON 架构,请参阅使用 theme.json 进行开发

设置

边框

与边框相关的设置。

属性 类型 默认值 属性表
customRadius boolean false

color

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

布局

与布局相关的设置。

属性 类型 默认值 属性说明
contentSize string
wideSize string

间距

与间距相关的设置。

属性 类型 默认值 属性表
customMargin boolean false
customPadding boolean false
units array px,em,rem,vh,vw,%

排版

与排版相关的设置。

属性 类型 默认值 参数
customFontSize boolean true
customLineHeight boolean false
dropCap boolean true
fontSizes array name, size, slug

custom

生成形式为 --wp--custom--{key}--{nested-key}: {value}; 的自定义 CSS 自定义属性。camelCased 格式的键名会转换为 kebab-case 以遵循 CSS 属性命名规范。不同深度的键名之间用 -- 分隔,因此键名中不应包含 --

样式

边框

边框样式。

属性 类型 参数
radius string

颜色

颜色样式。

属性 类型 参数
background string
gradient string
text string

间距

间距样式。

属性 类型 参数
margin object bottom, left, right, top
padding object bottom, left, right, top

排版

排版样式。

属性 类型 参数
fontSize string
lineHeight string