Change the Default Space Between Blocks
Sets the default vertical gap between blocks across a block theme, for a tighter or airier rhythm without adjusting every Group block.
Opens WPIDE on
Code
// Default gap between blocks.
$wpide_block_gap = '1.5rem';
add_filter( 'wp_theme_json_data_theme', function ( $theme_json ) use ( $wpide_block_gap ) {
return $theme_json->update_with( array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'styles' => array( 'spacing' => array( 'blockGap' => $wpide_block_gap ) ),
) );
} );
Notes
Any CSS length works, including clamp() values.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.