Skip to content

Add/configurable viewport values theme json#76475

Draft
ramonjd wants to merge 3 commits intotrunkfrom
add/configurable-viewport-values-theme-json
Draft

Add/configurable viewport values theme json#76475
ramonjd wants to merge 3 commits intotrunkfrom
add/configurable-viewport-values-theme-json

Conversation

@ramonjd
Copy link
Member

@ramonjd ramonjd commented Mar 13, 2026

What?

Allows themes to override the default mobile (480px) and tablet (782px) breakpoint sizes via settings.responsive.viewports in theme.json.

The three viewport slugs (mobile, tablet, desktop) remain fixed; only the pixel values can change. Desktop has no size value and cannot be overridden.

Why?

How?

Testing Instructions

Add some custom sizes for mobile and tablet and check if they work in the editor and frontend:

Example theme.json:

{
	"settings": {
	  "responsive": {
	    "viewports": [
	      { "slug": "mobile", "size": "100px" },
	      { "slug": "tablet", "size": "1000px" }
	    ]
	  }
}
  1. Set a block to hidden on mobile. Confirm the generated CSS uses width <= 100px instead of width <= 480px
  2. Set a block to hidden on tablet. Confirm 100px < width <= 1000px
  3. Resize the editor window below 100px — block should show as hidden in the editor
  4. Remove viewports from theme.json — defaults (480px, 782px) should restore
  5. Set an invalid value (e.g. "size": "30rem") — defaults should be used silently

ramonjd added 2 commits March 13, 2026 14:07
…rt definitions for block visibility, allowing themes to override mobile and tablet sizes via theme.json. Updated useBlockVisibility to utilize this new hook and replaced useViewportMatch with useMediaQuery for improved responsiveness. Add tests.
@ramonjd ramonjd self-assigned this Mar 13, 2026
@ramonjd ramonjd added the [Type] Experimental Experimental feature or API. label Mar 13, 2026
@github-actions github-actions bot added the [Package] Block editor /packages/block-editor label Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Type] Experimental Experimental feature or API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant