Skip to content

Adding class on preview (mobile, tablet, desktop, ...) to visual-editor or body #23430

@Vanillabacke

Description

@Vanillabacke

Hallo,

For developing an block that has an responsive behavior, it would be nice to get a class like "preview-tablet" for the visual editor, sidebar or best case for the body in the backend. An advantage for it would be, that you can easily use it in the block css and it would directly effect the style without checking the container width in the script.

Some event for that would be nice too, so that you can use it in the script as well.

For example, I'm building an wrapper for some components that you can change the value for different breakpoints and it would be nice, that you can use this state of the visual editor to detect the current view.

Another nice to have would be anyways to have the components repsonsive ready. For example you have an block and you should be able to change the values (padding, margin, width, align, font-size, ...) for some breakpoints. (see the image)
The values could be returned like this

{
default: 10,
mobile: undefined, // or null, false, ...
tablet: 30,
desktop: 60
}

example for responsive components
example for responsive components

cheers

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions