You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tracking the next layer of work to make block visibility configurable by themes and extensible for future responsive features.
Context
Block visibility ships in WordPress 7.0 with three hardcoded viewport sizes: Mobile (≤480px), Tablet (480px–782px), Desktop (>782px). These values are duplicated across PHP (lib/block-supports/block-visibility.php) and JS (packages/block-editor/src/components/block-visibility/constants.js), with no connection to theme.json or the existing SCSS breakpoints in packages/base-styles/_breakpoints.scss.
The scope for 7.0 was intentionally narrow to ship on time, but the hardcoded nature creates limitations:
Themes cannot define their own breakpoints to match their design systems.
The breakpoint values differ from common frameworks and from WordPress's own admin breakpoints (600px, 782px).
The viewport definitions in the editor (preview dropdown) and in block visibility are separate constants with no shared source of truth (noted as a @todo in constants.js).
The style engine is bypassed for display property handling — a KSES filter allowlists display as a workaround (lib/compat/wordpress-7.0/kses.php).
There is no way for themes to disable block visibility or control it per block type, unlike other block supports.
Block visibility is the first feature to generate per-block CSS within media queries. Establishing a solid, centralized foundation now — before more viewport-aware features arrive — avoids retrofitting later. This work does not implement responsive editing of other block properties, but it should not preclude it either.
Goals (to be decided)
1. Centralize breakpoint definitions (TBD)
Viewport sizes are currently defined independently in at least four places:
Location
Values
Format
lib/block-supports/block-visibility.php
480px, 782px
PHP array with name, slug, size
packages/block-editor/.../constants.js
desktop, tablet, mobile (no pixel values)
JS object with label, icon, key
packages/editor/.../preview-dropdown/index.js
Desktop, Tablet, Mobile
Inline array with labels
packages/base-styles/_breakpoints.scss
480px, 600px, 782px, 960px...
SCSS variables
These need to converge on a single canonical definition. The likely path is PHP (reading from theme.json with defaults) passed to JS via editor settings, but the exact mechanism needs discussion.
2. Theme-configurable breakpoints in theme.json
Extend the theme.json schema so themes can define viewport breakpoints. The exact schema location and shape need discussion — key design questions include:
Where in the theme.json structure do breakpoints belong? (Top-level settings? Under settings.layout? A new settings.responsive key?)
Should themes be able to define more or fewer than three breakpoints? What are the UI constraints?
How do theme-defined breakpoints interact with fluid typography and spacing values that already provide responsive behavior via clamp()?
What are the sensible defaults, and should they match the current visibility values (480px, 782px) or align with the broader WordPress admin breakpoints (600px, 782px)?
3. theme.json settings to control block visibility
Relies on agreement of JSON structure with 2. Theme-configurable breakpoints in theme.json
Allow themes to disable block visibility globally or per block type, following the same patterns as other block supports (e.g., color, spacing, typography). The mechanism should be consistent with how themes already opt in or out of block support features.
Per-block-type opt-out via block.json already works today, e.g., block_has_support( $block_type, 'visibility', true )
4. Bundling CSS with global styles rather than at run time in block supports
Depends on 2. Theme-configurable breakpoints in theme.json
The media query generation logic should live in a place where other features can reuse it, that implies WP_Theme_JSON generating the viewport utility classes as part of the global stylesheet — not embedded in block visibility rendering. Following this, whether the breakpoint-to-media-query mapping should be a style engine concern, a block supports concern, or a theme.json processing concern.
How to do this? Inline in WP_Theme_JSON adds to bloat. Does the style engine need to be extended to handle this as an exception, e.g., as with fluid typography?
Breakpoint format: Should breakpoints use range syntax (width <= 480px) as they do now, or min/max-width for broader browser compatibility? The current implementation uses CSS range syntax which is modern but relatively new.
Attribute validation: If breakpoints become theme-configurable, how do we validate blockVisibility.viewport attribute keys against the available breakpoints? What happens when a theme changes its breakpoints and existing content references old slugs?
Container queries: Some community discussion (Blocks: States #57719) suggests container queries may be more appropriate than viewport queries for block-level responsiveness. Should the breakpoint infrastructure account for container queries as a future possibility, or is that a separate concern?
Important
This is the first version of this issue - it may change in scope after WordPress 7.0.
Follow-up to:
Tracking the next layer of work to make block visibility configurable by themes and extensible for future responsive features.
Context
Block visibility ships in WordPress 7.0 with three hardcoded viewport sizes: Mobile (≤480px), Tablet (480px–782px), Desktop (>782px). These values are duplicated across PHP (
lib/block-supports/block-visibility.php) and JS (packages/block-editor/src/components/block-visibility/constants.js), with no connection totheme.jsonor the existing SCSS breakpoints inpackages/base-styles/_breakpoints.scss.The scope for 7.0 was intentionally narrow to ship on time, but the hardcoded nature creates limitations:
@todoinconstants.js).displayproperty handling — a KSES filter allowlistsdisplayas a workaround (lib/compat/wordpress-7.0/kses.php).Block visibility is the first feature to generate per-block CSS within media queries. Establishing a solid, centralized foundation now — before more viewport-aware features arrive — avoids retrofitting later. This work does not implement responsive editing of other block properties, but it should not preclude it either.
Goals (to be decided)
1. Centralize breakpoint definitions (TBD)
Viewport sizes are currently defined independently in at least four places:
lib/block-supports/block-visibility.phpname,slug,sizepackages/block-editor/.../constants.jsdesktop,tablet,mobile(no pixel values)label,icon,keypackages/editor/.../preview-dropdown/index.jsDesktop,Tablet,Mobilepackages/base-styles/_breakpoints.scssThese need to converge on a single canonical definition. The likely path is PHP (reading from
theme.jsonwith defaults) passed to JS via editor settings, but the exact mechanism needs discussion.2. Theme-configurable breakpoints in theme.json
Extend the
theme.jsonschema so themes can define viewport breakpoints. The exact schema location and shape need discussion — key design questions include:theme.jsonstructure do breakpoints belong? (Top-levelsettings? Undersettings.layout? A newsettings.responsivekey?)clamp()?Elaborated upon in the following comment: #75707 (comment)
3. theme.json settings to control block visibility
Relies on agreement of JSON structure with 2. Theme-configurable breakpoints in theme.json
Allow themes to disable block visibility globally or per block type, following the same patterns as other block supports (e.g.,
color,spacing,typography). The mechanism should be consistent with how themes already opt in or out of block support features.Per-block-type opt-out via block.json already works today, e.g.,
block_has_support( $block_type, 'visibility', true )Related comment: #75707 (comment)
4. Bundling CSS with global styles rather than at run time in block supports
Depends on 2. Theme-configurable breakpoints in theme.json
The media query generation logic should live in a place where other features can reuse it, that implies WP_Theme_JSON generating the viewport utility classes as part of the global stylesheet — not embedded in block visibility rendering. Following this, whether the breakpoint-to-media-query mapping should be a style engine concern, a block supports concern, or a
theme.jsonprocessing concern.How to do this? Inline in WP_Theme_JSON adds to bloat. Does the style engine need to be extended to handle this as an exception, e.g., as with fluid typography?
Related comment: #75707 (comment)
5. Miscellaneous fixes and enhancements
Open questions
width <= 480px) as they do now, or min/max-width for broader browser compatibility? The current implementation uses CSS range syntax which is modern but relatively new.blockVisibility.viewportattribute keys against the available breakpoints? What happens when a theme changes its breakpoints and existing content references old slugs?Stretch goals
Assumptions and risks
The scope will be affected by:
Out of scope
Related