Change the default Container padding

By default, the Container block has 40px of padding.

If you want to change this default, you can use this filter:

add_filter( 'generateblocks_defaults', function( $defaults ) {
    $defaults['container']['paddingTop'] = '0';
    $defaults['container']['paddingRight'] = '0';
    $defaults['container']['paddingBottom'] = '0';
    $defaults['container']['paddingLeft'] = '0';

    return $defaults;
} );
3 Likes

Thanks Tom. Is there any way of applying a default to only the mobile padding?

Thanks

@Tom I’m wondering the same thing as JayKay, is there a way to set default padding only for mobile?

You can add Tablet or Mobile to target those screen sizes.

Note that each smaller screen size inherits the size above, so if Desktop, Tablet, and Mobile are all 30px you only need to set Desktop. If Desktop and Tablet are 40px and Mobile is 20px you only need to set Desktop and Mobile.

add_filter( 'generateblocks_defaults', function( $defaults ) {
    $defaults['container']['paddingTop'] = '60';
    $defaults['container']['paddingRight'] = '60';
    $defaults['container']['paddingBottom'] = '60';
    $defaults['container']['paddingLeft'] = '60';
    $defaults['container']['paddingTopTablet'] = '40';
    $defaults['container']['paddingRightTablet'] = '40';
    $defaults['container']['paddingBottomTablet'] = '40';
    $defaults['container']['paddingLeftTablet'] = '40';
    $defaults['container']['paddingTopMobile'] = '20';
    $defaults['container']['paddingRightMobile'] = '20';
    $defaults['container']['paddingBottomMobile'] = '20';
    $defaults['container']['paddingLeftMobile'] = '20';

    return $defaults;
} );
4 Likes

Awesome, thanks alot!

That’s great, thanks!