This proposal was merged to core Core is the set of software required to run WordPress. The Core Development Team builds WordPress. Core is the set of software required to run WordPress. The Core Development Team builds WordPress. in [36532]. Download the latest nightly build and give it a try!
The customizer Tool built into WordPress core that hooks into most modern themes. You can use it to preview and modify many of your site’s appearance settings. is a framework for live-previewing changes to WordPress sites. And by now, nearly every WordPress theme/site features responsive designs intended to look good on any device. Previewing site changes is just important on mobile as it is on desktop, to ensure that front-end user experience is exactly as intended.
Bringing these ideas together, #31195 proposes a new feature in the customizer that allows users to quickly preview their site on various device sizes. Here’s a quick walkthrough:

The proposed feature focuses on simplicity. The device previewer is in the customizer controls footer, near the “Collapse” button. Only three options are available by default, and they’re intentionally ambiguous. Rather than looking like specific devices, the intent is to understand what a site may look like on a roughly tablet-sized, portrait-orientation device or a roughly phone-sized device, in addition to the standard desktop view. A further extension in #34051 may allow larger screen sizes to be previewed on smaller devices with forced horizontal scrolling; for now, the feature is only available on larger devices.
For Developers
Along with this feature would come a couple of ways to customize the behavior. Please keep in mind that these are proposed and subject to change.
The new customize_previewable_devices filter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. lets you customize the devices available for preview. One use case may be to turn off this feature entirely:
add_filter( 'customize_previewable_devices', '__return_empty_array' );
Or, developers can add additional custom device preview buttons. The button element will be rendered and the appropriate JS JavaScript, a web scripting language typically executed in the browser. Often used for advanced user interfaces and behaviors. applied to custom devices when the button is clicked; however, developers need to provide CSS Cascading Style Sheets. to add an icon to the button and to react React is a JavaScript library that makes it easy to reason about, construct, and maintain stateless and stateful user interfaces.
https://reactjs.org to the preview size changing.
In JavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser.
https://www.javascript.com, themes and plugins can react to changes in the device size being previewed with:
wp.customize.previewedDevice.bind( function( newDevice ) {
// Do something to adapt to the new device being previewed.
});
This is particularly useful if your theme requires a JS trigger for responsive elements to apply, instead of using CSS solely.
Summary
Any feedback and testing is much appreciated. Device previews in the Customizer can be tested with the latest patch A special text file that describes changes to code, by identifying the files and lines which are added, removed, and altered. It may also be referred to as a diff. A patch can be applied to a codebase for testing. on #31195.
Comments are welcome on this post, the ticket Created for both bug reports and feature development on the bug tracker. (#31195), or our continuous chat in #core-customize on Slack.
#customize, #mobile, #needs-testing
You must be logged in to post a comment.