How to implement spacing.blockGap support in custom block?
-
I have custom block with
spacing.blockGap : true
inblock.json
(I just copied it fromgroup
block)"supports": { "spacing": { "margin": true, "padding": true, "blockGap": true, "__experimentalDefaultControls": { "padding": true, "blockGap": true } } },
This block is just a wrapper with some css grid styles.
// save.js export default function save(props) { const innerBlocksProps = useInnerBlocksProps.save(useBlockProps.save()); return (<div {...innerBlocksProps}></div>) } // edit.js export default function Edit() { const innerBlocksProps = useInnerBlocksProps( useBlockProps(), { allowedBlocks: ['my-theme/inner-block'], }); return (<div {...innerBlocksProps}></div>) }
How do I implement
gap
support?The editor displays control for editing.
And When I save I get correct value in attributes:
<!-- wp:my-theme/outer-block {"style":{"spacing":{"blockGap":"var:preset|spacing|60"}}} --> <div class="wp-block-my-theme-outer-block"> <!-- wp:my-theme/inner-block --> ... <!-- /wp:my-theme/inner-block --> </div> <!-- /wp:my-theme/outer-block-->
But in front-end
gap
doesn’t applyed to this block.At the same time if I create build-in
group
block and setblockGap
in front end WP adds new classwp-container-6
withgap
styles.What should I do to tell WP add gap-classes to my block?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to implement spacing.blockGap support in custom block?’ is closed to new replies.