Skip to content

Box and IconButton create clipPath issue or cause anti aliasing artifacts #45024

@williamtober

Description

@williamtober

Steps to reproduce

Steps:

  1. Example CodeSandbox
  2. Place Box anywhere with a border radius and a background color...
  3. Have an element who's border radius would cause an overflow outside of the Box's borderRadius... borderRadius: 0
  4. Set the Box to overflow: 'clip' OR overflow: 'hidden'... it doesn't matter it still does the same thing..
  5. At the bottom right and top right corners of the Box element... we should now see the background of the Box element... where it should be showing the backgroundColor of our IconButton... it slightly leaks out... like we're talking single digit pixels

Current behavior

Box's background color leaks out near edges of borderRadius when overflow is set to clip or hidden even when the element at the clip position is passing the clip path with a different background color.

Expected behavior

Box's background color should not be visible at the edges of borderRadius when overflow is set to clip or hidden and the backgroundColor of the child element underneath the clip path should show...

Context

I want the box component's border radius to not ignore the elements rendered when overflow is set to clip or hidden. The the clip path margin should be set towards the content... as far as I understand... I'm always open to being wrong 😄

Your environment

npx @mui/envinfo
System:
    OS: macOS 15.2
  Binaries:
    Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
    pnpm: 9.14.2 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.265
    Edge: Not Found
    Safari: 18.2
  npmPackages:
    @emotion/react: ^11.13.3 => 11.13.3 
    @emotion/styled: ^11.13.0 => 11.13.0 
    @mui/base: ^5.0.0-beta.40 => 5.0.0-beta.40 
    @mui/core-downloads-tracker:  6.0.1 
    @mui/icons-material: ^6.0.1 => 6.0.1 
    @mui/material: ^6.0.1 => 6.0.1 
    @mui/private-theming:  6.0.1 
    @mui/styled-engine:  6.0.1 
    @mui/styled-engine-sc: ^6.0.2 => 6.0.2 
    @mui/system:  6.0.1 
    @mui/types:  7.2.16 
    @mui/utils:  6.0.1 
    @mui/x-data-grid: ^7.21.0 => 7.21.0 
    @mui/x-date-pickers: ^7.16.0 => 7.16.0 
    @mui/x-internals:  7.16.0 
    @types/react: ^18.2.15 => 18.3.5 
    react: ^18.2.0 => 18.3.1 
    react-dom: ^18.2.0 => 18.3.1 
    styled-components: ^6.1.13 => 6.1.13 
    typescript: ^5.0.2 => 5.5.4

I've been able to recreate this on Google Chrome, Safari, and Edge.

Search keywords: backgroundColor, borderRadius, overflow, artifact, clipPath, firstIssue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions