Skip to content

Add options to offset block margins. #24504

Closed

Description

@alaczek

Is your feature request related to a problem? Please describe.

Here's a fairly popular pattern I've been trying to accomplish:

image

This is mostly possible with image and paragraph blocks (here nested inside a columns block), but there's no way to overlap the paragraph/heading with an image.

For comparison here's what I was able to put together in the editor right now:

image

(also, in addition to margin controls, we would need a way to limit block width)

I'm not sure what would be the best way to implement this - having an option of setting margins including a negative one maybe?

Activity

  1. added
    [Type] Enhancement
    [Feature] Patterns
    on Aug 17, 2020
  2. ellatrix commented on Aug 17, 2020

    @ellatrix
    Member

    Hm, interesting. If a pattern were a block, you'd be able to add some styles specific for this block. But since it's just a pattern (and has no wrapper block), this is not possible. Adding margin attributes to every block etc. seems a bit like overkill. Maybe each block should have advanced CSS attributes? Or in this case, a custom block would be better? Cc @youknowriad @mtias

  3. youknowriad commented on Aug 20, 2020

    @youknowriad
    Contributor

    I don't think margin for every block is overkill personally but an advanced feature (opt-in potentially).

    That said a "custom CSS" per block can also be a similarly good advanced feature. (I recall this being discussed in the past too).

  4. added
    [Feature] Design Tools
    on Aug 20, 2020
  5. alaczek commented on Aug 24, 2020

    @alaczek
    Author

    Or in this case, a custom block would be better?

    Not sure this is the way to go. Overlapping images with text is just one of the use cases. Ideally, we could overlap any two blocks. I do agree this would be a more advanced feature and I like the idea of "custom CSS". We could then build patterns to make those more advanced designs accessible to anyone.

  6. LevinMedia commented on Aug 27, 2020

    @LevinMedia

    I don't think margin for every block is overkill personally but an advanced feature (opt-in potentially).

    I agree @youknowriad. However, I would say it's not opt in, it's just there in the sidebar settings for a block if you want to use it. I've been looking at the columns block, and the child column blocks recently, and I came to the same conclusion: adding margin and padding controls to all blocks would be very useful. In particular, when you start using Gutenberg to build templates and template parts, or edit complex layouts, that level of control is necessary. IMO Having having to rely on custom CSS to get that level of control defeats the purpose of visual editing.

    @alaczek I think what you're trying to do could be done if both the image block, and the paragraph block had margin and padding controls.

    The image block could be set to have no margin. The paragraph block would have a background color + padding applied, to create the size of the box you want around the text. Negative top margin would get it to overlay the image above. I think you'd also need a z-index control to get the text to sit above the image. The margin and padding controls for the paragraph box might look something like this (using the box control component)

    Screen Shot 2020-08-27 at 2 41 18 PM

  7. iamtakashi commented on Sep 1, 2020

    @iamtakashi

    I came to the same conclusion: adding margin and padding controls to all blocks would be very useful. In particular, when you start using Gutenberg to build templates and template parts, or edit complex layouts, that level of control is necessary. IMO Having having to rely on custom CSS to get that level of control defeats the purpose of visual editing.

    +1 👍👍👍

  8. ramonjd commented on Aug 9, 2021

    @ramonjd
    Member

    By removing the min attribute in the margin control box (essentially setting inputProps={ { min: undefined } }) we can allow negative margins:

    Screen Shot 2021-08-09 at 10 08 51 pm

    The above effect uses a group block (is there another, more suitable block?), but note that I had to add position relative to create a new stacking context in order that it appears over its sibling elements.

  9. moved this to Not Started in Design Tools Projecton Nov 2, 2021
  10. removed
    [Feature] Patterns
    on Jun 29, 2023
  11. Mamaduka commented on Jul 10, 2024

    @Mamaduka
    Member

    I think we can close this. Negative margins shipped in Gutenberg 18.3 and should be part of WordPress 6.6 release.

  12. moved this from ⏱ Not Started to ✅ Done in Design Tools Projecton Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Design Tools[Type] Enhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions