{"id":124535,"date":"2026-08-05T06:50:06","date_gmt":"2026-08-05T06:50:06","guid":{"rendered":"https:\/\/make.wordpress.org\/core\/?p=124535"},"modified":"2026-08-06T18:22:34","modified_gmt":"2026-08-06T18:22:34","slug":"responsive-block-styles-and-configurable-viewports-in-wordpress-7-1","status":"publish","type":"post","link":"https:\/\/make.wordpress.org\/core\/2026\/08\/05\/responsive-block-styles-and-configurable-viewports-in-wordpress-7-1\/","title":{"rendered":"Responsive block styles and configurable viewports in WordPress 7.1"},"content":{"rendered":"<p class=\"wp-block-paragraph\">WordPress 7.1 introduces <a href=\"https:\/\/core.trac.wordpress.org\/ticket\/65164\">responsive style states for blocks<\/a>. Styles can now be defined for Tablet and Mobile viewports both through Global Styles for each <span tabindex='0' class='glossary-item-container'>block<span class='glossary-item-hidden-content'><span class='glossary-item-header'>Block<\/span> <span class='glossary-item-description'>Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience.<\/span><\/span><\/span> type and on individual block instances. They can be applied to all block types (and their block style variations) that use <a href=\"https:\/\/developer.wordpress.org\/block-editor\/reference-guides\/block-api\/block-supports\/\">core block supports<\/a> such as typography, color, background, border, dimensions, spacing, and layout.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The default style remains the base style and applies at every viewport. Tablet and Mobile styles override that base within their respective breakpoint ranges.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is now also possible to define custom values for the Tablet and Mobile viewports, using <code>px<\/code>, <code>em<\/code> or <code>rem<\/code> units.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Defining responsive block styles in<\/strong> <strong>`theme.<span tabindex='0' class='glossary-item-container'>json<span class='glossary-item-hidden-content'><span class='glossary-item-header'>JSON<\/span> <span class='glossary-item-description'>JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML.<\/span><\/span><\/span>`<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">\"styles\": {\n\t\t\"blocks\": {\n\t\t\t\"core\/group\": {\n\t\t\t\t\"spacing\": {\n\t\t\t\t\t\"padding\": {\n\t\t\t\t\t\t\"top\": \"3rem\",\n\t\t\t\t\t\t\"right\": \"3rem\",\n\t\t\t\t\t\t\"bottom\": \"3rem\",\n\t\t\t\t\t\t\"left\": \"3rem\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"@mobile\": {\n\t\t\t\t\t\"spacing\": {\n\t\t\t\t\t\t\"padding\": {\n\t\t\t\t\t\t\t\"top\": \"1rem\",\n\t\t\t\t\t\t\t\"right\": \"1rem\",\n\t\t\t\t\t\t\t\"bottom\": \"1rem\",\n\t\t\t\t\t\t\t\"left\": \"1rem\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Responsive and pseudo-states are nested from viewport to pseudo-state:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">\"styles\": {\n\t\t\"blocks\": {\n\t\t\t\"core\/button\": {\n\t\t\t\t\"@mobile\": {\n\t\t\t\t\t\":hover\": {\n\t\t\t\t\t\t\"color\": {\n\t\t\t\t\t\t\t\"background\": \"var:preset|color|contrast\",\n\t\t\t\t\t\t\t\"text\": \"var:preset|color|base\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Block instance attributes<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Responsive styles for an individual block are stored in the block\u2019s existing <code>style<\/code> attribute, using the same <code>@mobile<\/code> and <code>@tablet<\/code> keys as Global Styles:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"markup\" class=\"language-markup\">&lt;!-- wp:paragraph {\"style\":{\"@mobile\":{\"typography\":{\"fontSize\":\"1rem\"}}}} --&gt;\n&lt;p&gt;Text with a responsive font size.&lt;\/p&gt;\n&lt;!-- \/wp:paragraph --&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On the frontend, WordPress generates media-query-scoped <span tabindex='0' class='glossary-item-container'>CSS<span class='glossary-item-hidden-content'><span class='glossary-item-header'>CSS<\/span> <span class='glossary-item-description'>Cascading Style Sheets.<\/span><\/span><\/span> for the responsive values and adds a stable, generated class to the rendered block. Non-layout per-instance state declarations are marked `!important` so they can override the block\u2019s default inline styles. Responsive layout values and `blockGap` are processed by the existing layout support and scoped with the block\u2019s generated container class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Configurable breakpoints<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress provides two responsive style breakpoints by default:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>State<\/th><th>Media query<\/th><\/tr><\/thead><tbody><tr><td><code>@mobile<\/code><\/td><td><code>@media (width &lt;= 480px)<\/code><\/td><\/tr><tr><td><code>@tablet<\/code><\/td><td><code>@media (480px &lt; width &lt;= 782px)<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">There is no <code>@desktop<\/code> style key. The block\u2019s default style is the desktop\/base style and continues to apply at smaller sizes for any property that is not overridden.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Themes can <a href=\"https:\/\/core.trac.wordpress.org\/ticket\/65596\">customize the breakpoint widths<\/a> with the new top-level <code>settings.viewport<\/code> values:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">\"settings\": {\n\t\t\"viewport\": {\n\t\t\t\"mobile\": \"30rem\",\n\t\t\t\"tablet\": \"45rem\"\n\t\t}\n\t}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This produces the following ranges:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"css\" class=\"language-css\">@media (width &lt;= 30rem) { \/* Mobile *\/ }\n@media (30rem &lt; width &lt;= 45rem) { \/* Tablet *\/ }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Breakpoint values must be non-negative numeric lengths using <code>px<\/code>, <code>em<\/code>, or <code>rem<\/code>. CSS functions, percentages, unitless values, and other units are ignored.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If only one valid breakpoint is configured, it keeps its viewport name and uses a single maximum-width query. If neither value is valid, the defaults are used. When both are valid but the Tablet value is smaller than or equal to the Mobile value, only the Mobile breakpoint is used.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The configured viewport widths are used by responsive block styles and block visibility, and are previewable via the editor\u2019s device preview.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>settings.viewport<\/code> is a top-level setting. It cannot be configured separately for individual block types.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Opting out of responsive editing<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Sites that need to prevent users from making viewport-based styling changes can <a href=\"https:\/\/github.com\/WordPress\/gutenberg\/pull\/80814\">turn off responsive style editing<\/a> with the <code>responsiveEditingEnabled<\/code> editor setting, which defaults to <code>true<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">function example_disable_responsive_editing( $settings ) {\n\t$settings['responsiveEditingEnabled'] = false;\n\treturn $settings;\n}\nadd_filter( 'block_editor_settings_all', 'example_disable_responsive_editing' );<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When it is <code>false<\/code>, both entry points for choosing a viewport are removed: the \u201cResponsive styles\u201d toggle in the Editor\u2019s View menu, and the \u201cViewport\u201d group in the \u201cStates\u201d dropdown in Global Styles. Device previews still work, and pseudo states such as Hover remain available.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The setting governs the editing interface only. Responsive styles already saved in <code>theme.json<\/code>, in Global Styles, or in a block\u2019s <code>style<\/code> attribute are left untouched, and the media-query CSS described above is still generated for them, so existing content renders exactly as before both in the Editor and on the front end.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Reviewed by <a href=\"https:\/\/profiles.wordpress.org\/tyxla\/\" class=\"mention\"><span class=\"mentions-prefix\">@<\/span>tyxla<\/a>; props <a href=\"https:\/\/profiles.wordpress.org\/ramonopoly\/\" class=\"mention\"><span class=\"mentions-prefix\">@<\/span>ramonopoly<\/a>, <a href=\"https:\/\/profiles.wordpress.org\/wildworks\/\" class=\"mention\"><span class=\"mentions-prefix\">@<\/span>wildworks<\/a><\/p>\n<p class=\"o2-appended-tags\"><a href=\"https:\/\/make.wordpress.org\/core\/tag\/7-1\/\" class=\"tag\"><span class=\"tag-prefix\">#<\/span>7-1<\/a>, <a href=\"https:\/\/make.wordpress.org\/core\/tag\/dev-notes\/\" class=\"tag\"><span class=\"tag-prefix\">#<\/span>dev-notes<\/a>, <a href=\"https:\/\/make.wordpress.org\/core\/tag\/dev-notes-7-1\/\" class=\"tag\"><span class=\"tag-prefix\">#<\/span>dev-notes-7-1<\/a><\/p><nav class='o2-post-footer-actions'><ul class='o2-post-footer-action-row'><li class='o2-post-footer-action'><a href=\"https:\/\/login.wordpress.org\/?redirect_to=https%3A%2F%2Fmake.wordpress.org%2Fcore%2F2026%2F08%2F05%2Fresponsive-block-styles-and-configurable-viewports-in-wordpress-7-1%2F%23respond&#038;locale=en_US\" title=\"Login to Reply\"  class=\"genericon  genericon-reply\"  data-action=\"login-to-reply\"  data-actionstate=\"default\" >Login to Reply<\/a><\/li><\/ul><div class='o2-post-footer-action-likes'><\/div><ul class='o2-post-footer-action-row'><\/ul><\/nav>","protected":false},"excerpt":{"rendered":"<p>WordPress 7.1 introduces responsive style states for blocks. Styles can now be defined for Tablet and Mobile viewports both through Global Styles for each blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts [&hellip;]<\/p>\n","protected":false},"author":14222470,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1175],"tags":[5885,1443,5894],"class_list":["post-124535","post","type-post","status-publish","format-standard","hentry","category-general","tag-7-1","tag-dev-notes","tag-dev-notes-7-1","mentions-ramonopoly","mentions-tyxla","mentions-wildworks","author-isabel_brison"],"revision_note":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2AvED-woD","jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/posts\/124535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/users\/14222470"}],"replies":[{"embeddable":true,"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/comments?post=124535"}],"version-history":[{"count":11,"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/posts\/124535\/revisions"}],"predecessor-version":[{"id":125308,"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/posts\/124535\/revisions\/125308"}],"wp:attachment":[{"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/media?parent=124535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/categories?post=124535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/make.wordpress.org\/core\/wp-json\/wp\/v2\/tags?post=124535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}