Block Wrapper Dynamic Class

The HTML structure inside the Block Editor may differ slightly from the one rendered on the frontend. Most notably, an extra wrapper <div> around the actual block content.

Inside Gutenberg editor, the <div> in the red box is a wrapper wrapping <section> which is the actual content. Of course the <div> wrapper is only for Gutenberg Editor to keep tracking and managing the blocks and not rendered in the frontend.

In this case, some CSS applied to the outermost element might not work. For eg, grid-column that requires the immediate parent to be a grid.

To solve this issue, users can add dynamic classes to outermost block wrapper using Block Wrapper Dynamic Class (under template settings -> Gutenbricks:Block.)

For example, you can declare something like cold-span-{dynamic_variable} and the dynamic class will be applied to the block wrapper like this:

col-span-5 has been applied to the block wrapper where "5" is from dynamic_variable.

Now you can see column-span working because the block wrapper which is the grid's immediate child has col-span-5 class.

Last updated