-
MattGP
Hi, is there a way to remove the default button padding?
The reason is that I use Global Styles for my buttons. (I know I can press the “clear local styles” button, but I was hoping we could avoid that step for a simple button.)
I’ve tried using this filter:
add_filter( 'generateblocks_defaults', function( $defaults ) { $color_settings = wp_parse_args( get_option( 'generate_settings', array() ), generate_get_color_defaults() ); $defaults['button']['paddingTop'] = ''; $defaults['button']['paddingRight'] = ''; $defaults['button']['paddingBottom'] = ''; $defaults['button']['paddingLeft'] = ''; return $defaults; } );
But that didn’t work since GenerateBlocks doesn’t accept empty values:
'spacing' => [ 'paddingTop' => $defaults['button']['paddingTop'] ? $defaults['button']['paddingTop'] : '15px', 'paddingRight' => $defaults['button']['paddingRight'] ? $defaults['button']['paddingRight'] : '20px', 'paddingBottom' => $defaults['button']['paddingBottom'] ? $defaults['button']['paddingBottom'] : '15px', 'paddingLeft' => $defaults['button']['paddingLeft'] ? $defaults['button']['paddingLeft'] : '20px', ]
(Source: generateblocks/includes/defaults.php)
Is there another way to remove the default padding-values?
Thank you!
-
Hi there,
the fields accept non-numeric unit values. So you could use that filter to set them all to
initial
-
MattGP
Thanks for your fast reply!
Changing the value to initial did remove the padding, but I couldn’t override this value with the padding-settings from my own Custom Style.
(I just noticed that the title of my thread should have been “Override default button-padding with Custom Style”).
As a workaround, I’ve created a CSS-variable with the same padding-values as in my Custom Style:
add_filter( 'generateblocks_defaults', function( $defaults ) { $defaults['button']['paddingTop'] = 'var(--button-padding)'; $defaults['button']['paddingRight'] = 'var(--button-padding)'; $defaults['button']['paddingBottom'] = 'var(--button-padding)'; $defaults['button']['paddingLeft'] = 'var(--button-padding)'; return $defaults; } );
It’s not perfect but it does the job for now 🙂
-
If you’re using a custom style, then i would say that probably is the perfect way 🙂
Glad to hear you got it working.
- You must be logged in to reply to this topic.