question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Masonry] `spacing` doesn't accept hard-coded string value

See original GitHub issue

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

I tried to add spacing={'24px'} to the Masonry component but it broke the Masonry layout as seen in the image below. image

If I used spacing={3} as the replacement of spacing={'24px'} for the Masonry component, the Masonry layout was fine as seen in the image below. image

I always use spacing={'24px'} to the Grid component and it works as seen in the image below. image

Expected behavior 🤔

The Masonry component should accept a string value for the spacing prop as stated in the Masonry API documentation here https://mui.com/api/masonry/ image

Steps to reproduce 🕹

Steps:

  1. Import the Masonry component
  2. Add spacing={'24px'} prop to the Masonry component
  3. The Masonry layout is broken

Context 🔦

Here is the demo: https://codesandbox.io/s/github-mui-masonry-xnlub

For me, this case is not really important since I could replace spacing={'24px'} with spacing={3}. But it could be important if someone wants to use custom spacing like 5px, 10px, etc.

Your environment 🌎

Environment

Dependencies: stated in the demo Browser: Chrome 97 OS: Windows 11

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
siriwatknpcommented, Feb 8, 2022

In my opinion, keeping the default unit to theme spacing and encouraging developers to customise theme is more healthy for several reasons

I agree that the spacing should not be hard-coded and should follow the theme spacing definition. If we have to provide an escape hatch, we should document the why and example use case.

1reaction
hbjORbjcommented, Feb 6, 2022

Hi, thanks for opening the issue.

As you can see in Masonry API doc, spacing is a factor of the theme's spacing.

But it could be important if someone wants to use custom spacing like 5px, 10px, etc.

MUI users can customise the value of theme spacing flexibly (as described in https://mui.com/customization/spacing/).

If we allow to accept hard-coded string or number, then we have to drop supporting theme spacing as the default unit of spacing prop. In my opinion, keeping the default unit to theme spacing and encouraging developers to customise theme is more healthy for several reasons. One of them is that MUI users who have not had an opportunity to customise theme are forced to try it, and this can benefit them over the long-run during the time they use any of MUI components.

@jaballogian What do you think?

cc @siriwatknp @michaldudak

Read more comments on GitHub >

github_iconTop Results From Across the Web

Are hard-coded STRINGS ever acceptable? - Stack Overflow
Let's assume that each of these config_option values really does correspond to a single problem domain (or implementation strategy) concept.
Read more >
Cascading Style Sheets (CSS) Working Group Teleconference -- 23 ...
column-fill in unconstrained containers; multicol tests; Masonry Layout ... He's thought in detail about what it would take to add something to Grid...
Read more >
Unreal Engine 5.1 Release Notes
What's New? Unreal Engine 5.0 was a groundbreaking release, bringing a whole slate of new tools to users. 5.1 is building upon the...
Read more >
DIVISION 600 MISCELLANEOUS CONSTRUCTION SECTION ...
When the Contractor elects to use SCC, the slump requirement for Class BZ Concrete does not apply. Class D concrete is a dense...
Read more >
Python program for word guessing game - GeeksforGeeks
This game is for beginners learning to code in python and to give them a little brief about using strings, loops, and conditional(If,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found