{"id":42646,"date":"2021-07-30T07:26:13","date_gmt":"2021-07-29T22:26:13","guid":{"rendered":"https:\/\/jirak.net\/wp\/configuring-theme-design-with-theme-json\/"},"modified":"2021-07-30T08:34:21","modified_gmt":"2021-07-29T23:34:21","slug":"configuring-theme-design-with-theme-json","status":"publish","type":"post","link":"https:\/\/jirak.net\/wp\/configuring-theme-design-with-theme-json\/","title":{"rendered":"Configuring Theme Design with theme.json"},"content":{"rendered":"<p>Configuring Theme Design with theme.json<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"356\" src=\"https:\/\/i2.wp.com\/wordpress.org\/news\/files\/2021\/07\/themejson-1.png?resize=632%2C356&#038;ssl=1\" alt=\"\" class=\"wp-image-11082\" data-recalc-dims=\"1\" \/><\/figure>\n<p>Starting in <a href=\"https:\/\/wordpress.org\/news\/2021\/07\/tatum\/\">WordPress 5.8<\/a>, a new tool \u2014 \u201ctheme.json\u201d \u2014 is available to use in your theme. Maybe you\u2019re hearing about it for the first time, or maybe you\u2019re testing and developing themes with it already.\u00a0Either way, I&#8217;m glad you&#8217;re here because it&#8217;s an exciting time for WordPress themes.<\/p>\n<p>This post provides a quick introduction to this new framework, and describes what\u2019s possible by sharing a few practical tips and examples.<\/p>\n<h2>What\u2019s theme.json?<\/h2>\n<p>Technically, theme.json is just a file that lives at the top-level of a theme\u2019s directory.&nbsp;<\/p>\n<p>Conceptually, it\u2019s a major shift in how themes can be developed. Theme authors now have a centralized mechanism to tailor the WordPress experience for site authors and visitors. Theme.json provides theme authors fine-grained control over global styles, block styles, and the block editor settings.<\/p>\n<p>By providing these settings and controls in a single file, theme.json provides a powerful framework that brings together many\u00a0aspects of theme design and development. And as the block editor matures and adds more features, theme.json will shine as the backbone for themes and the editor to work <em>together<\/em> <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4aa.png\" alt=\"\ud83d\udcaa\" class=\"wp-smiley\" style=\"height: 1em;max-height: 1em\" \/>.\u00a0<\/p>\n<h2>Why Use it?<\/h2>\n<p>It\u2019s the future! But if you\u2019re like me, you might need something more tangible to be convinced. Here are a few reasons why you might use theme.json today:<\/p>\n<ul>\n<li>Control editor settings like color, typography, spacing, and layout, and consolidate where these settings are managed.<\/li>\n<li>Guarantee that styles apply correctly to blocks and elements across your site.<\/li>\n<li>Reduce the amount of boilerplate CSS a theme used to provide. Theme.json won&#8217;t replace your stylesheet completely \u2014 there will be instances where CSS is needed to give your theme that extra flare (transitions, animations, etc.). But it can greatly reduce the base CSS needed from the theme.<\/li>\n<\/ul>\n<h2>How do I use it?<\/h2>\n<p>The rest of this post demonstrates a few theme.json configurations you can try out.\u00a0The examples use the tt1-blocks<a href=\"https:\/\/github.com\/WordPress\/theme-experiments\/blob\/master\/tt1-blocks\/theme.json\"> theme.json<\/a> \u2014 <a href=\"https:\/\/wordpress.org\/themes\/tt1-blocks\/\">the block-based version of this year\u2019s default theme<\/a>.\u00a0<\/p>\n<p>If you&#8217;re starting with an existing theme, you might try copying a theme.json from the <a href=\"https:\/\/github.com\/WordPress\/theme-experiments\/\">WordPress\/theme-experiments repository<\/a> (for example, <a href=\"https:\/\/github.com\/WordPress\/theme-experiments\/blob\/master\/fse-tutorial\/theme.json\">the fse-tutorial theme<\/a> by <a href=\"https:\/\/profiles.wordpress.org\/poena\/\">@poena<\/a>) and adding it to the root of your theme\u2019s directory.<\/p>\n<h3><strong>Change the typography settings of your site globally<\/strong><\/h3>\n<div class=\"wp-block-syntaxhighlighter-code \">\n<pre class=\"brush: jscript; title: ; notranslate\">\n&quot;settings&quot;: {\n\t&quot;typography&quot;: {\n\t\t&quot;fontSize&quot;: &quot;30px&quot;,\n\t\t...\n<\/pre>\n<\/div>\n<p>Making the change above in theme.json would result in the following updates to your theme&#8217;s body typography styles (before and after): <\/p>\n<figure class=\"wp-block-gallery columns-2 is-cropped\">\n<ul class=\"blocks-gallery-grid\">\n<li class=\"blocks-gallery-item\">\n<figure><a href=\"https:\/\/i1.wp.com\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.06.07-AM.png?ssl=1\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"398\" src=\"https:\/\/i1.wp.com\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.06.07-AM.png?resize=632%2C398&#038;ssl=1\" alt=\"\" data-id=\"11062\" data-full-url=\"https:\/\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.06.07-AM.png\" data-link=\"https:\/\/wordpress.org\/news\/?attachment_id=11062\" class=\"wp-image-11062\" data-recalc-dims=\"1\" \/><\/a><\/figure>\n<\/li>\n<li class=\"blocks-gallery-item\">\n<figure><a href=\"https:\/\/i1.wp.com\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.05.40-AM.png?ssl=1\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"398\" src=\"https:\/\/i1.wp.com\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.05.40-AM.png?resize=632%2C398&#038;ssl=1\" alt=\"\" data-id=\"11061\" data-full-url=\"https:\/\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.05.40-AM.png\" data-link=\"https:\/\/wordpress.org\/news\/?attachment_id=11061\" class=\"wp-image-11061\" data-recalc-dims=\"1\" \/><\/a><\/figure>\n<\/li>\n<\/ul>\n<\/figure>\n<h3><strong>Changing the base color settings of your site globally<\/strong><\/h3>\n<div class=\"wp-block-syntaxhighlighter-code \">\n<pre class=\"brush: jscript; title: ; notranslate\">\n&quot;styles&quot;: {\n\t&quot;color&quot;: {\n\t\t&quot;background&quot;: &quot;#ffc0cb&quot;,\n\t\t&quot;text&quot;: &quot;#6A1515&quot;\n\t},\n\t...\n}\n<\/pre>\n<\/div>\n<figure class=\"wp-block-gallery columns-2 is-cropped\">\n<ul class=\"blocks-gallery-grid\">\n<li class=\"blocks-gallery-item\">\n<figure><a href=\"https:\/\/i2.wp.com\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.10.03-AM.png?ssl=1\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"398\" src=\"https:\/\/i2.wp.com\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.10.03-AM.png?resize=632%2C398&#038;ssl=1\" alt=\"\" data-id=\"11063\" data-full-url=\"https:\/\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.10.03-AM.png\" data-link=\"https:\/\/wordpress.org\/news\/?attachment_id=11063\" class=\"wp-image-11063\" data-recalc-dims=\"1\" \/><\/a><\/figure>\n<\/li>\n<li class=\"blocks-gallery-item\">\n<figure><a href=\"https:\/\/i2.wp.com\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.08.54-AM.png?ssl=1\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"398\" src=\"https:\/\/i2.wp.com\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.08.54-AM.png?resize=632%2C398&#038;ssl=1\" alt=\"\" data-id=\"11064\" data-full-url=\"https:\/\/wordpress.org\/news\/files\/2021\/07\/Screen-Shot-2021-07-23-at-11.08.54-AM.png\" data-link=\"https:\/\/wordpress.org\/news\/?attachment_id=11064\" class=\"wp-image-11064\" data-recalc-dims=\"1\" \/><\/a><\/figure>\n<\/li>\n<\/ul>\n<\/figure>\n<h3><strong><strong>Changing spacing \/ padding settings on specific blocks<\/strong><\/strong><\/h3>\n<div class=\"wp-block-syntaxhighlighter-code \">\n<pre class=\"brush: jscript; title: ; notranslate\">\n&quot;styles&quot;: {\n\t&quot;blocks&quot;: {\n\t\t&quot;core\/code&quot;: {\n\t\t\t&quot;spacing&quot;: {\n\t\t\t\t&quot;padding&quot;: {\n\t\t\t\t\t&quot;top&quot;: &quot;3em&quot;,\n\t\t\t\t\t&quot;bottom&quot;: &quot;3em&quot;,\n\t\t\t\t\t&quot;left&quot;: &quot;3em&quot;,\n\t\t\t\t\t&quot;right&quot;: &quot;3em&quot;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n<\/pre>\n<\/div>\n<figure class=\"wp-block-gallery columns-2 is-cropped\">\n<ul class=\"blocks-gallery-grid\">\n<li class=\"blocks-gallery-item\">\n<figure><a href=\"https:\/\/i2.wp.com\/wordpress.org\/news\/files\/2021\/07\/code-padding-original.png?ssl=1\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"356\" src=\"https:\/\/i2.wp.com\/wordpress.org\/news\/files\/2021\/07\/code-padding-original.png?resize=632%2C356&#038;ssl=1\" alt=\"\" data-id=\"11065\" data-full-url=\"https:\/\/wordpress.org\/news\/files\/2021\/07\/code-padding-original.png\" data-link=\"https:\/\/wordpress.org\/news\/?attachment_id=11065\" class=\"wp-image-11065\" data-recalc-dims=\"1\" \/><\/a><\/figure>\n<\/li>\n<li class=\"blocks-gallery-item\">\n<figure><a href=\"https:\/\/i1.wp.com\/wordpress.org\/news\/files\/2021\/07\/code-padding-edited.png?ssl=1\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"356\" src=\"https:\/\/i0.wp.com\/wordpress.org\/news\/files\/2021\/07\/code-padding-edited-1024x576.png?resize=632%2C356&#038;ssl=1\" alt=\"\" data-id=\"11066\" data-full-url=\"https:\/\/wordpress.org\/news\/files\/2021\/07\/code-padding-edited.png\" data-link=\"https:\/\/wordpress.org\/news\/?attachment_id=11066\" class=\"wp-image-11066\" data-recalc-dims=\"1\" \/><\/a><\/figure>\n<\/li>\n<\/ul>\n<\/figure>\n<h3><strong><strong>Set a custom color palette in the editor for specific blocks like a button <\/strong><\/strong><\/h3>\n<div class=\"wp-block-syntaxhighlighter-code \">\n<pre class=\"brush: jscript; title: ; notranslate\">\n&quot;settings&quot;: {\n    &quot;blocks&quot;: {\n\t\t&quot;core\/button&quot;: {\n\t\t\t&quot;color&quot;: {\n\t\t\t\t&quot;palette&quot;: &#091; \n\t\t\t\t\t{\n\t\t\t\t\t\t&quot;name&quot;: &quot;Maroon&quot;,\n\t\t\t\t\t\t&quot;color&quot;: &quot;#6A1515&quot;,\n\t\t\t\t\t\t&quot;slug&quot;: &quot;maroon&quot;\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t&quot;name&quot;: &quot;Strawberry Ice Cream&quot;,\n\t\t\t\t\t\t&quot;color&quot;: &quot;#FFC0CB&quot;,\n\t\t\t\t\t\t&quot;slug&quot;: &quot;strawberry-ice-cream&quot;\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t}\n}\n<\/pre>\n<\/div>\n<figure class=\"wp-block-gallery columns-2 is-cropped\">\n<ul class=\"blocks-gallery-grid\">\n<li class=\"blocks-gallery-item\">\n<figure><a href=\"https:\/\/i0.wp.com\/wordpress.org\/news\/files\/2021\/07\/button-all-colors.png?ssl=1\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"444\" src=\"https:\/\/i0.wp.com\/wordpress.org\/news\/files\/2021\/07\/button-all-colors.png?resize=632%2C444&#038;ssl=1\" alt=\"\" data-id=\"11069\" data-full-url=\"https:\/\/wordpress.org\/news\/files\/2021\/07\/button-all-colors.png\" data-link=\"https:\/\/wordpress.org\/news\/?attachment_id=11069\" class=\"wp-image-11069\" data-recalc-dims=\"1\" \/><\/a><\/figure>\n<\/li>\n<li class=\"blocks-gallery-item\">\n<figure><a href=\"https:\/\/i1.wp.com\/wordpress.org\/news\/files\/2021\/07\/buttons-custom-palette.png?ssl=1\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"444\" src=\"https:\/\/i1.wp.com\/wordpress.org\/news\/files\/2021\/07\/buttons-custom-palette.png?resize=632%2C444&#038;ssl=1\" alt=\"\" data-id=\"11070\" data-full-url=\"https:\/\/wordpress.org\/news\/files\/2021\/07\/buttons-custom-palette.png\" data-link=\"https:\/\/wordpress.org\/news\/?attachment_id=11070\" class=\"wp-image-11070\" data-recalc-dims=\"1\" \/><\/a><\/figure>\n<\/li>\n<\/ul>\n<\/figure>\n<h3><strong><strong>Enable and disable typography controls<\/strong><\/strong><\/h3>\n<p>In the following example, the ability to supply a custom font size and line height for all heading blocks is disabled:<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \">\n<pre class=\"brush: jscript; title: ; notranslate\">\n\t&quot;settings&quot;: {\n\t\t&quot;blocks&quot;: {\n\t\t\t&quot;core\/heading&quot;: {\n\t\t\t\t&quot;typography&quot;: {\n\t\t\t\t\t&quot;customFontSize&quot;: false,\n\t\t\t\t\t&quot;customLineHeight&quot;: false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n<\/pre>\n<\/div>\n<figure class=\"wp-block-gallery columns-2 is-cropped\">\n<ul class=\"blocks-gallery-grid\">\n<li class=\"blocks-gallery-item\">\n<figure><a href=\"https:\/\/i1.wp.com\/wordpress.org\/news\/files\/2021\/07\/heading-all-options.png?ssl=1\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"444\" src=\"https:\/\/i1.wp.com\/wordpress.org\/news\/files\/2021\/07\/heading-all-options.png?resize=632%2C444&#038;ssl=1\" alt=\"\" data-id=\"11071\" data-full-url=\"https:\/\/wordpress.org\/news\/files\/2021\/07\/heading-all-options.png\" data-link=\"https:\/\/wordpress.org\/news\/?attachment_id=11071\" class=\"wp-image-11071\" data-recalc-dims=\"1\" \/><\/a><\/figure>\n<\/li>\n<li class=\"blocks-gallery-item\">\n<figure><a href=\"https:\/\/i2.wp.com\/wordpress.org\/news\/files\/2021\/07\/heading-no-line-height-custom-size.png?ssl=1\"><img decoding=\"async\" loading=\"lazy\" width=\"632\" height=\"444\" src=\"https:\/\/i2.wp.com\/wordpress.org\/news\/files\/2021\/07\/heading-no-line-height-custom-size.png?resize=632%2C444&#038;ssl=1\" alt=\"\" data-id=\"11072\" data-full-url=\"https:\/\/wordpress.org\/news\/files\/2021\/07\/heading-no-line-height-custom-size.png\" data-link=\"https:\/\/wordpress.org\/news\/?attachment_id=11072\" class=\"wp-image-11072\" data-recalc-dims=\"1\" \/><\/a><\/figure>\n<\/li>\n<\/ul>\n<\/figure>\n<h2>What&#8217;s Next?<\/h2>\n<p>I hope this gives you a sense of what&#8217;s possible and where themes are going. The above examples just scratch the surface of what kinds of theme design configurations are possible, and I\u2019m very excited to see what theme authors create.<\/p>\n<p>If you&#8217;re interested in learning more, <a href=\"https:\/\/make.wordpress.org\/core\/2021\/06\/25\/introducing-theme-json-in-wordpress-5-8\/\">here&#8217;s the developer note on theme.json<\/a>, and <a href=\"https:\/\/developer.wordpress.org\/block-editor\/how-to-guides\/themes\/theme-json\/\">here&#8217;s the documentation for theme.json<\/a> in the handbook.<\/p>\n<hr class=\"wp-block-separator is-style-wide\" \/>\n<p><em><strong>Thanks to <a href=\"https:\/\/profiles.wordpress.org\/kjellr\/\">@kjellr<\/a>, <a href=\"https:\/\/profiles.wordpress.org\/chanthaboune\/\">@<\/a><\/strong><\/em><strong><em><a href=\"https:\/\/profiles.wordpress.org\/chanthaboune\/\">chanthaboune<\/a>, <a href=\"https:\/\/profiles.wordpress.org\/priethor\/\">@priethor<\/a>, <a href=\"https:\/\/profiles.wordpress.org\/annezazu\/\">@annezazu<\/a> for helping with and peer-reviewing this post.<\/em><\/strong><\/p>\n<p>Source: <a href=\"https:\/\/wordpress.org\/news\/2021\/07\/configuring-theme-design-with-theme-json\/\" target=\"_blank\" rel=\"noopener\">Configuring Theme Design with theme.json<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Configuring Theme Design with theme.json Starting in WordPress 5.8, a new tool \u2014 \u201ctheme.json\u201d \u2014 is available to use in your theme. Maybe you\u2019re hearing about it for the first time, or maybe you\u2019re testing and developing themes with it already.\u00a0Either way, I&#8217;m glad you&#8217;re here because it&#8217;s an exciting time for WordPress themes. This post provides a quick introduction to this new framework, and describes what\u2019s possible by sharing a few practical tips and examples. What\u2019s theme.json? Technically, theme.json is just a file that lives at the top-level of a theme\u2019s directory.&nbsp; Conceptually, it\u2019s a major shift in how themes can be developed. Theme authors now have a centralized mechanism to tailor the WordPress experience for site authors and visitors. Theme.json provides theme authors fine-grained control over global styles, block styles, and the block editor settings. By providing these <a class=\"mh-excerpt-more\" href=\"https:\/\/jirak.net\/wp\/configuring-theme-design-with-theme-json\/\" title=\"Configuring Theme Design with theme.json\">[ more&#8230; ]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[169],"tags":[395],"class_list":["post-42646","post","type-post","status-publish","format-standard","hentry","category-news","tag-wordpress"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/posts\/42646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/comments?post=42646"}],"version-history":[{"count":1,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/posts\/42646\/revisions"}],"predecessor-version":[{"id":42647,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/posts\/42646\/revisions\/42647"}],"wp:attachment":[{"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/media?parent=42646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/categories?post=42646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/tags?post=42646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}