Skip to content

Add option for clipping Group block content based on border radius of root Group block - #87176

Open
Vedant-Gandhi wants to merge 2 commits into
WordPress:trunkfrom
Vedant-Gandhi:feat/group-clip-content-to-radius
Open

Vedant-Gandhi wants to merge 2 commits into
WordPress:trunkfrom
Vedant-Gandhi:feat/group-clip-content-to-radius

Conversation

@Vedant-Gandhi

Copy link
Copy Markdown
Contributor

What?

Closes #52559.

Adds an opt-in "Clip content to rounded corners" setting to the Group block, in the Border panel.

Why?

A Group's border radius rounds the Group itself, but nested blocks with their own background still show square corners that stick out of it. Today the only fix is custom CSS.

How?

  • New optional hasClippedContent attribute. When it's on, save adds the has-clipped-content class, which sets overflow: clip (with overflow: hidden as a fallback).
  • The switch only shows when the Group has a border radius, or when it's already on.
  • It's opt-in, so existing Groups keep the same markup and look. Clipping every rounded Group automatically could cut off content that sticks out on purpose, such as shadows or full-width children.

Testing Instructions

  1. Add a Group with a visible background and set a border radius of 24px in the Border panel.
  2. Inside it, add an Image or a Cover block, or a Paragraph with a background color. The inner corners stick out of the rounded corners.
  3. In the Border panel, turn on "Clip content to rounded corners". The nested blocks now follow the rounded corners.
  4. View the post on the front end. The corners are clipped there too.
  5. Turn the switch off, or use the Border panel's "Reset all". The nested blocks stick out again.
  6. Remove the border radius. The switch is hidden.
  7. Open an existing post with a rounded Group. It looks the same as before.
  8. With the switch on, check that the block appender and the block toolbar still show up when you add a block inside the Group.

Screenshots or screencast

image

Use of AI Tools

I used Claude Sonnet 5.5 to debug the code, find exact file and pair test the code, the changelog entry and the PR description. I have reviewed everything and checked that there are no unintended side effects from AI.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @porg.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: porg.

Co-authored-by: Vedant-Gandhi <vedantgandhi28@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Group block: border-radius attribute to achieve rounded edges only clips content on bottom but not on top

1 participant