Skip to content

Consider adding support for content alignment on parent blocks #57346

Open

Description

@mikachan

What problem does this address?

I've noticed recently that a common use case is setting a unified content/text alignment on nested blocks. For example, centering all headings and paragraphs in a group block. Currently, the only way to do this is to set the text alignment on each block individually.

What is your proposed solution?

Allow blocks that are often used as parents (group, column) to set alignment that propagates to any nested blocks. This might need to cover both text alignment and justification settings, depending on the nested blocks, and depending on how many blocks we'd want this to affect.

Activity

  1. added
    [Type] Enhancement
    [Block] Columns
    [Block] Group
    [Feature] Design Tools
    on Dec 22, 2023
  2. Marc-pi commented on Dec 25, 2023

    @Marc-pi

    yep, frequent usage, i do confirm the need for whoever builds frequently his theme from the UI.

  3. Nyiriland commented on Apr 17, 2024

    @Nyiriland

    Came here to say I would also gladly use this feature.

  4. benoitchantre commented on Jun 5, 2025

    @benoitchantre
    Contributor

    @Mamaduka I have tried to add textAlign support to the group block. My expectation was to get the related control, but it didn't appear.

    "typography": {
    	"fontSize": true,
    	"lineHeight": true,
    	"textAlign": true,
    	"__experimentalFontFamily": true,
    	"__experimentalFontWeight": true,
    	"__experimentalFontStyle": true,
    	"__experimentalTextTransform": true,
    	"__experimentalTextDecoration": true,
    	"__experimentalLetterSpacing": true,
    	"__experimentalDefaultControls": {
    		"fontSize": true
    	}
    },

    https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-textalign

  5. Mamaduka commented on Jun 12, 2025

    @Mamaduka
    Member

    @benoitchantre, how are you modifying the supports arguments for the Group block? The following example works in my tests.

    add_filter( 'register_block_type_args', function( $args, $block_type ) {
    	if ( 'core/group' === $block_type ) {
    		$args['supports']['typography']['textAlign'] = true;
    	}
    
    	return $args;
    }, 10, 2 );

    Screenshot

    Image

  6. benoitchantre commented on Jun 12, 2025

    @benoitchantre
    Contributor

    @Mamaduka Thank you for your feedback. I have directly updated the block.json file, but I don't remember exactly what I did. This was the first time I used the wp-env environment and maybe I missed something during the Contributor Day, as I was also working on a patch for core.

    I checked again today and can confirm this is working as expected with the same result as your screenshot 🎉

    What are your thoughts on this issue? That seems to be a nice enhancement for the content editors.

  7. Mamaduka commented on Jun 24, 2025

    @Mamaduka
    Member

    Sorry for the late reply, @benoitchantre, I was on vacation.

    What are your thoughts on this issue? That seems to be a nice enhancement for the content editors.

    @t-hamano, worked on this feature. He might have more details on why it's not implemented in core for container blocks. Meanwhile, the snippet I shared can be used to enable the feature on the consumer side.

  8. t-hamano commented on Jun 24, 2025

    @t-hamano
    Contributor

    I don't have a strong opinion on whether to add text alignment support to container blocks. However, the problem is that text alignment cannot be overridden at the block instance level. This is why none of the core blocks support text alignment yet. See #62260 (comment) for more details.

    To be more specific, if we add support for this to the Group block in the following way:

    diff --git a/packages/block-library/src/group/block.json b/packages/block-library/src/group/block.json
    index 3c7d8d3ce1..7fec1aab14 100644
    --- a/packages/block-library/src/group/block.json
    +++ b/packages/block-library/src/group/block.json
    @@ -74,6 +74,7 @@
                            "sticky": true
                    },
                    "typography": {
    +                       "textAlign": true,
                            "fontSize": true,
                            "lineHeight": true,
                            "__experimentalFontFamily": true,

    If we center text via the global styles and then left-justify text in a block instance, the style won't actually be prioritized.

    f1e02f653e4dad3d00871679bde5857d.mp4
  9. benoitchantre commented on Jun 24, 2025

    @benoitchantre
    Contributor

    Thank you for your feedbacks and the additional information.

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

    [Block] Columns[Block] Group[Feature] Design Tools[Type] Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions