material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[Masonry] Component not centered due to a default margin at -8

Open SanNic20 opened this issue 3 years ago • 1 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Steps to reproduce 🕹

No response

Current behavior 😯

Component not centered due to a default margin at -8

Expected behavior 🤔

margin will be at 0

Context 🔦

No response

Your environment 🌎

No response

SanNic20 avatar Sep 15 '22 08:09 SanNic20

It doesn't look like this bug report has enough info for one of us to reproduce it.

Please provide a CodeSandbox (https://mui.com/r/issue-template), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem.

Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

ZeeshanTamboli avatar Sep 19 '22 05:09 ZeeshanTamboli

@ZeeshanTamboli . If you look at the component with the browser dev tool, you see that by default there is a margin of -8 which shifts the masonry slightly to the left and top

image

SanNic20 avatar Sep 23 '22 14:09 SanNic20

@ZeeshanTamboli . If you look at the component with the browser dev tool, you see that by default there is a margin of -8 which shifts the masonry slightly to the left and top

image

Okay, I am not sure whether it's a bug or is intentional. I'll move it back to "status: needs triage". @hbjORbj Will take a look and confirm.

ZeeshanTamboli avatar Sep 24 '22 06:09 ZeeshanTamboli

This is by design. As you can see in the following code snippet, the negative margin to the wrapper is provided in order to offset the margin applied to each child. https://github.com/mui/material-ui/blob/0246ec2cdd85de48c669da3f84e25f0dd7eb51f0/packages/mui-lab/src/Masonry/Masonry.js#L95-L99

hbjORbj avatar Oct 06 '22 10:10 hbjORbj