Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to add padding to certain blocks #15084

Closed
RobinRoelofsen opened this issue Apr 20, 2019 · 10 comments
Closed

Add ability to add padding to certain blocks #15084

RobinRoelofsen opened this issue Apr 20, 2019 · 10 comments
Labels
[Block] Group Affects the Group Block (and row, stack and grid variants) Needs Decision Needs a decision to be actionable or relevant Needs Design Needs design efforts.

Comments

@RobinRoelofsen
Copy link

RobinRoelofsen commented Apr 20, 2019

Love the new group block! Just noticed that adding a background color doesn't add padding to the block as it does when adding a background color to a paragraph block.

I solved it for my situation by adding these lines to my CSS:

.wp-block-group.has-background {
    padding: 20px 30px;
}

I understand that adding padding is not always desirable when using the group block, since the items often need to line up with the rest of the block.

Proposed solution: add padding boxes to the block settings sidebar for both the group block and the paragraph block, so the user can set their own preferred padding when applicable.

@RobinRoelofsen RobinRoelofsen changed the title Adding ability to add padding to the group block Adding ability to add padding to certain blocks Apr 20, 2019
@RobinRoelofsen RobinRoelofsen changed the title Adding ability to add padding to certain blocks Add ability to add padding to certain blocks Apr 20, 2019
@jorgefilipecosta jorgefilipecosta added [Block] Group Affects the Group Block (and row, stack and grid variants) Needs Design Needs design efforts. Needs Decision Needs a decision to be actionable or relevant labels Apr 22, 2019
@youknowriad
Copy link
Contributor

Adding a background actually adds padding by default.

when it comes to the possibility to tweak these paddings, that might be something to consider and this is a duplicate of #14747

@RobinRoelofsen
Copy link
Author

Adding a background to the Groups block does NOT add padding by default.

It does when adding a background to a paragraph block.

@youknowriad
Copy link
Contributor

@RobinRoelofsen It might a theme conflict or something, I just made a Gif showing that the group block adds padding. In this example I have a paragraph block within a group block. Both have backgrounds and paddings.

padding

@RobinRoelofsen
Copy link
Author

@RobinRoelofsen It might a theme conflict or something, I just made a Gif showing that the group block adds padding. In this example I have a paragraph block within a group block. Both have backgrounds and paddings.

padding

@youknowriad Yes, it does because you add a background to the paragraph block as well.

When I create a group block with a background color, I would not expect to also add a background color to the blocks I add to the group block. Is that a wrong assumption?

@youknowriad
Copy link
Contributor

It does no matter the content of the group block, as soon as you add the background to the group block, a padding is added, that's the current behavior.

@RobinRoelofsen
Copy link
Author

Shoot, trying it with Twenty Nineteen and it does! Not with GeneratePress, though.

Please accept my apologies. I guess I am too 'forward' using the Gutenberg plugin with a block that's not officially out yet...

@youknowriad
Copy link
Contributor

Thanks, no apologies needed and very happy you're using the plugin and providing feedback. That's what help us find bugs and iterate before hitting Core.

@RobinRoelofsen
Copy link
Author

Busy writing a WP guide including an extensive look into the block editor. That's why I am using the latest version, so I'm always up to date ;-)

@ethanclevenger91
Copy link

ethanclevenger91 commented Oct 27, 2021

@youknowriad

It does no matter the content of the group block, as soon as you add the background to the group block, a padding is added, that's the current behavior.

That's not something built into Gutenberg. That's a theme-specific style added to Twenty Nineteen and, presumably, other core themes. The following is from the Twenty Nineteen stylesheet:

.entry .entry-content .wp-block-group.has-background {
  padding: 1rem;
  margin-top: 0;
  margin-bottom: 0;
}

The Gutenberg style.css has padding styles applied to p.has-background, .wp-block-columns.has-background, and potentially others, but not the group block.

The Gutenberg theme.css file has broader support, using .wp-block-group:where(.has-background) as the selector. But that file is not enqueued on the front end. Only in the editor.

@Ezyweb-uk
Copy link

In WP v6.0.1 I noticed that padding is only applied when the group style was changed from the default 'column' style to 'cover'. I had created the group and moved a shortcode block into that group. When I tried returning the group style to 'column' it added another group. I retested creating a group and adding a paragraph block, no padding was applied and no theme conflict evident in Inspector. The default style this time was 'cover', but I had to click 'cover' before the padding was applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Group Affects the Group Block (and row, stack and grid variants) Needs Decision Needs a decision to be actionable or relevant Needs Design Needs design efforts.
Projects
None yet
Development

No branches or pull requests

5 participants