Title: Default block.json margin values
Last modified: November 17, 2023

---

# Default block.json margin values

 *  [jonhecky](https://wordpress.org/support/users/jonhecky/)
 * (@jonhecky)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/default-block-json-margin-values/)
 *     ```wp-block-code
       {
           "$schema": "https://schemas.wp.org/trunk/block.json",
           "name": "acf/hero-two",
           "title": "Hero Two",
           "description": "A custom hero_two block that uses ACF fields.",
           "category": "formatting",
           "icon": "admin-comments",
           "keywords": ["hero_two", "hero", "toggle", "collapse"],
           "acf": {
               "mode": "preview",
               "renderTemplate": "hero-two.php"
           },
           "attributes": {
               "style": {
                   "type": "object",
                   "default": {
                       "spacing": {
                           "margin": {
                               "top": "32px"
                           }
                       }
                   }
               }
           },
           "supports": {
               "align": true,
               "spacing": {
                   "margin": true,
                   "padding": true
               },
               "anchor": true,
               "alignContent": false,
               "color": {
                   "text": false,
                   "background": false,
                   "link": false
               },
               "alignText": false,
               "fullHeight": false
           }
       }
       ```
   
 * Hello, I setup my block.json like this and when I load the block in the block
   editor and look under the styles tab it gets set to the “32px” however when I
   go the the front end where I am applying these styles with `<?= get_block_wrapper_attributes();?
   >` nothing is output. if I remove these settings in block.json and set a spacing
   value normally the function sets the styles without any issue.
   Why is it showing
   me that 32px is set on the slider, but the style is never passed to the front
   end? Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Mario Santos](https://wordpress.org/support/users/santosguillamot/)
 * (@santosguillamot)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/default-block-json-margin-values/#post-17215023)
 * Hello [@jonhecky](https://wordpress.org/support/users/jonhecky/)!
 * It seems there is an issue with these default values in dynamic blocks. It has
   been reported in [this GitHub issue](https://github.com/WordPress/gutenberg/issues/50229)
   and, apart from those reporting it there, I have been able to reproduce it as
   well. I already shared this ticket to keep track of it there, but I invite you
   to share your feedback and follow the discussion.
 * The only thing I can think of right now is to “workaround” it somehow with the
   following code, but **this is far from being ideal, and we should probably wait
   until that issue is fixed in core**. Sharing just in case it helps somehow.
 *     ```wp-block-code
       <?php
       	$marginTop = isset( $attributes['style']['spacing']['margin']['top'] ) ? $attributes['style']['spacing']['margin']['top'] : '100px';
       ?>
   
       <div
       	<?php echo get_block_wrapper_attributes(); ?>
       	style="<?php echo "margin-top: " . $marginTop . ";" ;?>"
       >
       	This is my block
       </div>
       ```
   
    -  This reply was modified 2 years, 6 months ago by [Mario Santos](https://wordpress.org/support/users/santosguillamot/).
 *  Thread Starter [jonhecky](https://wordpress.org/support/users/jonhecky/)
 * (@jonhecky)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/default-block-json-margin-values/#post-17215556)
 * Thanks for reporting it and linking those other tickets, can’t believe I didn’t
   run across them.
 * I had your workaround for a few days before removing it and letting css specificity
   handle it instead, as getblockwrapperattributes sets the inline styles properly
   when I remove the default settings attempt in block.json. so I just set a default
   margin via tailwind/css.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Default block.json margin values’ is closed to new replies.

## Tags

 * [attributes](https://wordpress.org/support/topic-tag/attributes/)
 * [block](https://wordpress.org/support/topic-tag/block/)
 * [blocks](https://wordpress.org/support/topic-tag/blocks/)
 * [dimensions](https://wordpress.org/support/topic-tag/dimensions/)
 * [json](https://wordpress.org/support/topic-tag/json/)
 * [spacing](https://wordpress.org/support/topic-tag/spacing/)
 * [style](https://wordpress.org/support/topic-tag/style/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [jonhecky](https://wordpress.org/support/users/jonhecky/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/default-block-json-margin-values/#post-17215556)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
