• Resolved charlie67p

    (@charlie67p)


    Hi!

    I made a block variation for the core/gallery block.

    I would like to set a block gap value inside this variation.

    Is it possible?

    Thanks

    • This topic was modified 1 year, 10 months ago by charlie67p.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi!

    Yes, it’s possble to supply style values in a block variation like so:

    wp.blocks.registerBlockVariation(
        'core/gallery',
        {
            name: 'my-gallery/my-gallery-variant',
            title: 'My Gallery Variant',
            attributes: {
                style: {
                    spacing: {
                        blockGap: '2em'
                    }
                }
            }
        }
        );
    Thread Starter charlie67p

    (@charlie67p)

    Thank you very much @akirk !

    Works fine using units like this :
    spacing: {
    blockGap: "25px"
    }


    But I tried with a variable and this don’t work.. Do you know why ?
    spacing: {
    blockGap: "var(--wp--preset--spacing--ecart-2)"
    }

    According to this Github issue this would be var:preset|spacing|ecart-2.

    Thread Starter charlie67p

    (@charlie67p)

    Just perfect !

    Thank you @akirk

    I mark as resolved

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Use block variation to set a gallery block gap’ is closed to new replies.