-
Notifications
You must be signed in to change notification settings - Fork 667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-grid-3][masonry] Masonry Syntax Designer/Developer Feedback #11060
Comments
I’d say masonry and grid are as at least different as grid and flex, so they should be separate Grid and flex share a lot of properties - almost all of the align and justification properties work on both, but justify-items is ignored for flex. I’d guess (correct me if I’m wrong) some options will be ignored for masonry. It’s a lot easier to document what properties are ignored if it depends solely on the layout mode without additional context, as is the case today. It’ll make for a fantastic table too! I believe the WebKit proposal makes it easier to describe an invalid layout too, if you put masonry layout for both columns and rows. This isn’t an absolute deal breaker - grid already did this with the named areas. But Chrome’s proposal doesn’t suffer from this - everything you write will create a computable layout (like flex) On the point too WebKit makes about code reuse through sharing properties - this isn’t the only way to do this. You could introduce Consider this a vote for Chrome’s proposal. Sorry WebKit 😅❤️ Edit- I spent a bit longer with Safari's demo implementation. I think it's neat that you enabled spanning over multiple tracks - I would have assumed it would be too difficult. I know it's a preview, so there are bugs, but what should |
I prefer the Grid-integrated syntax, because of WebKit's biggest argument: it should easy to learn and the design principle says to build on what's already available in CSS. Learning a whole other set of properties just for collapsing some rows in a grid (because that's what masonry is imho) sounds very cumbersome, rather unnecessary and even inaccessible to me. |
Thank you for that great article, @jensimmons. It really made it click for me, how the options differ and what the DX will feel like. I'm in favour of the Grid-integrated syntax, as it feels like a natural extension of CSS Grid's capabilities. As you mentioned in your article, that's probably because I've used CSS grid a lot. The ability to just tweak a couple of CSS Grid properties in a media query – instead of changing the entire layout mode – really hits home for me. Looking at all those new properties in the Grid-independent syntax makes my brain hurt. Just use grid! 😅 |
I definitely feel it should be a part of |
Also, I don't have an issue with the |
While I was already convinced that extending the Grid syntax is the right way forward, something immediately stood out to me in the latest WebKit post, emphasis mine:
I’ve personally experienced this many times, needing different layouts for various screen sizes. I can vividly imagine how cumbersome it would be to use different syntaxes for the same HTML at different breakpoints. This realistic scenario further solidifies my belief that extending our existing tools (Grid, in this case) is the right approach. Imagine how much more powerful the minimally extended Grid syntax would be when combined with CSS Variables. You could not only adjust the layout but completely change it by updating just the CSS variables at a given breakpoint. |
Initially my intuitions lead me towards wanting a separate After reading the article, however, I'm strongly convinced of the integrated "Just use grid" approach. The distinction visually between a grid and a masonry layout is not sufficient for an entirely new display property. Masonry really is just a flavour of grid, or even a collapsed grid. I like the I see the distinction somewhat similar to the difference between Just use grid! |
There is so much overlap between grid and masonry that it feels really strange to duplicate all that syntax. I also don't think masonry is going to be used all that much in the real world (once Pinterest design becomes easy it will also become untrendy) so having an entire set of keywords dedicated to it feels like a pollution of keywords. I'm not sure the defaults for masonry syntax advocated by the Chrome team is very useful either, given that it will often need to be overriden or be redeclared just to be explicit. The only downside I see for integrated grid syntax is that new features of grid need to take masonry into consideration. I don't know what is in the pipeline for grid so I don't know how much of an issue that actually is. Given all of this I vote for the grid integrated syntax |
Conceptually, this specific layout is still some kind of a grid, so it makes sense to keep it as a sub-functionality of I am worried about the adoption of a new display type when there are still people not interested in learning grid. It would be another syntax to learn, which is only somewhat close to the grid syntax. I vote for the grid-integrated syntax |
I don't really follow your argument. If some people aren't interested in learning grid, how will making grid even more complicated help? If we use a different syntax for masonry, maybe these people will learn this other simpler syntax. |
Thanks, I see how it was not clear enough. I would assume that people not having learned grid by now, would also not learn the new masonry syntax. These will likely not use it regardless. But there are people who postponed it for longer. For these / beginners / most people having to learn just a few more keywords is far easier / the burden of entry far lower than to learn a whole new display type. |
Masonry feels like an exotic use-case. If it has to be incorporated in the CSS spec I'd argue for making it a separate rule. CSS Grid is complex enough as is. |
An independent masonry (grid) feature would (in my mind) allow it to grow in less gridlike ways. It would be about masonry and not about grids. The nature of masonry, with its dynamic placement, makes it a candidate for more variations of placing content dynamically. Do masonry tracks need to be straight lines? Could we have spirals? Assign 'boxes' with priority/preference that directly or indirectly influence the dynamic placement of content. I fear if it's an extension of the current grid, the door to a new, alternative layout will be more challenging to open. I apologise if any of this has been mentioned before. |
Masonry should be its own layout type. Same as with other layouts there is always some overlap. We could make the same arguments for flexbox yet we have not combined it, and that's a good thing. Also from a learning perspective, it is easier to learn some one new masonry specific properties and values, instead trying to make them learn both grid and masonry and what properties and values don't work together |
I think with whatever we decide, the masonry layout should be enabled using the Also, the WebKit team have proposed expanding some of the |
If I was a developer who didn't understand However, if I was a developer who did understand grid layouts, being able to apply my existing knowledge to masonry would feel like much less of a burden than needing to learn a whole new set of concepts for masonry (or even just needing to memorize how grid properties map to masonry properties). The breakpoints use case mentioned by the Webkit team and others here is also particularly compelling. Even the grid novice would probably prefer to only need to tweak one or two properties they half-understand rather than try to wrangle a whole new set of CSS properties. |
The WebKit article asserts that the “just use grid” option would make it easier to switch between grid and masonry at a breakpoint. I’d like to see one or more examples that demonstrate this, as it’s not entirely clear to me that the two layouts would share enough declarations to make this easier or clearer than a separate display type. |
I'm strongly in favor of introducing a separate display type, such as I've explored content from the WebKit and Chrome teams, along with other blogs and videos, and have worked on multiple layouts that ideally would use a masonry approach (e.g., a wall of reviews or a Pinterest clone). From my perspective, adding masonry to the existing grid model introduces unnecessary complexity—both technically and conceptually. Here are two examples that underscore why masonry and grid are inherently different: Problem 1: Confusion with Masonry on Both Axes.masonry {
display: grid;
grid-template-columns: masonry;
grid-template-rows: masonry;
} What would happen in this case? Is it just up to developers to remember to avoid this configuration? This ambiguity indicates a fundamental mismatch between masonry and grid. Problem 2: Over Complication When Changing the Masonry Axis (esp. with template areas)Not to mention, 'areas' isn't an ideal concept for defining rows or columns in a masonry layout. .masonry {
display: grid;
grid-template-areas: "a b c";
grid-template-rows: masonry;
}
/* Switch masonry direction. */
.masonry {
grid-template-areas: "a" "b" "c"; /* Each row is quoted. */
grid-template-rows: unset;
grid-template-columns: masonry;
} Re-declaring template areas like this makes it clear that we are stretching the grid model beyond its intended use to fit masonry behavior. These are just two examples, but there are undoubtedly many more—both existing and yet to come—that illustrate the challenges of merging grid and masonry. Moreover, I'm not seeing any compelling advantages in tying the two together, especially when the conceptual separation could be much cleaner and easier to use. IMHO introducing a dedicated display type would provide a clearer, more intuitive approach to handling these kinds of layouts, avoiding the complexity and ambiguity that arise from trying to force masonry behavior into the existing grid framework. Footnotes |
I want to ensure that my layout doesn’t break if |
I prefer the idea of leveraging the existing grid syntax and properties. Masonry seems to be an extension of grid. Grid is a good, generic concept for creating many specific layouts, of which masonry is but one endpoint. Masonry is a tweak or modification; a style of grid. Elevating a specific way of displaying boxes on a grid to a whole new I can very easily imagine myself starting with "grid" layout at the onset of a project and needing to switch to masonry style later. I would need to rewrite a bunch of CSS if it was its own On the second point of what to call it if it was a keyword for |
Firstly, I am happy that this is coming to CSS. It will be a great addition to the new layout methods I've read both the blog posts from the WebKit and the Chrome team and I do see valid points in both of them. Webkits proposal of having all the existing power of However, I think that the But making some values invalid in some specific cases is not a good idea. I am therefore voting for a separate |
I'd argue this is burdening the future for the sake of the present. The fallback for an unsupported |
My points have already been stated in this thread, so I'll just vote: Make Masonry part of Grid! |
@HeyHemi-dev I think the argument was in favour of a separate display keyword so you could write a grid layout and a masonry layout, and have it fall back automatically. Although we do have supports queries now so not so sure it’s a deal breaker |
I don't understand that comparison: |
I recommend creating a separate specification for masonry. While the current grid specification can handle masonry layouts for now, the future of masonry is uncertain. Adding masonry rules to the grid specification could increase its complexity significantly. |
After reading the article from Jen Simmons i'm also for the integrated grid syntax. This just make sense. A masonry layout is at the end of the day just a variation of a grid, so with some settings in grid, it should be possible to describe the flow of the masonry. |
Here's another vote for Grid Integrated - the argument from webkit is compelling and I feel no reason to repeat it here, but I'll add that this approach feels more syntactically cohesive from a responsibility perspective. |
My 2 cents: integrating masonry into Overall, I'm "meh, why?" on incorporating masonry into the browser as I don't find it a friendly experience for people that have issues with focus or cognitive challenges. It's a perennial issue getting people to be aware of and care about inclusivity in design and engineering; using From what I can see, the Other thoughts:
|
@ziofat Fair point, consistency is preferable. |
This table, and the argument based off of it...kind of confuses me:
...why do we keep adding a display type prefix to what is essentially the same property. The author keeps talking about cognitive overhead and confusing syntax, but then gives the example of using grid properties in a flow layout: article {
display: block; /* default value, unnecessary to state */
grid-template-columns: 1fr 1fr minmax(15ch, 30ch) minmax(15ch, 30ch) 1fr;
grid-default-column: 3 / 5;
} How is this not equally confusing as the New Masonry Display option? Why don't we just...drop the prefix? Then we have: article {
display: block; /* default value, unnecessary to state */
template-columns: 1fr 1fr minmax(15ch, 30ch) minmax(15ch, 30ch) 1fr;
default-column: 3 / 5;
} And if we want to change |
Thoughts, with the caveat that I'm not deep in the weeds of how specifications or CSS works behind the scenes, I'm just a developer who uses it every day. (Though I guess that's exactly who you want to feed back on this!) I prefer the grid-integrated syntax for a number of reasons:
Footnotes
|
I also initially favoured Chrome's proposal but after reading WebKit's justification for "Just Use Grid", I agree with their reasoning for
Both of these support Just Use Grid instead of having to learn an entire new syntax and layout system. |
I wrote my quick thoughts as a blogpost: https://argonaut-constellation.org/2024/10/27/masonry-syntax.html Probably could've made it a comment, but I like putting in the context of my blog! Again, my vote is: Just use grid! |
I wrote about my thoughts here: https://ishadeed.com/article/css-grid-masonry/. In short, I vote for integrating masonry as part of CSS grid. |
@shadeed thanks for all the examples in your post! I’m working through the practical example in 4.2, which (I think) uses grid at larger widths, masonry at smaller widths, but reverts to grid if it contains a Your display:masonry version (with my additional comment) .masonry {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
padding: 1rem;
@media (min-width: 700px) {
display: masonry;
masonry-template-tracks: repeat(3, 1fr);
gap: 10px;
padding: 0;
&:has(.card-fixed) {
display: grid;
/* also reset gap and padding? */
/* but any grid- or masonry-specific differences are OK */
}
}
} My “just use grid” version .just-use-grid {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
padding: 1rem;
@media (min-width: 700px) {
grid-template-columns: repeat(3, 1fr);
grid-template-rows: masonry;
gap: 10px;
padding: 0;
&:has(.card-fixed) {
grid-template-columns: 1fr;
grid-template-rows: none;
/* also reset gap and padding? */
/* and reset anything else in grid that differs */
}
}
} To my eye the nested grid-masonry-grid decisions look more clear and simple with a display change. |
I'd like to see it integrated into CSS Grids. My conclusion is, that, practically all Layouts in some form are originating from a grid system. That alone wouldn't be a good reason for a technical decision. Yet, having read Ahmad Shadeeds thorough examination and having had a brief look at the Webkit Teams article, I think there is/might be just this "underlying principle" at work, which would allow this solution to be so elegant. Especially the So, it is nonetheless constructed on a grid system. Even one/two column layouts, simple type areas in books—the laying of the text body, page numbers, etc.—are fundamentally based on a grid system, which has been constructed beforehand in the design process. Ask designers! (Disclaimer: I studied graphic design before ending up as some IT guy) One might be afraid to overload Masonry is a very particular instance of a layout, grids/grid systems are the principle. PS: I also prefer to remove the term "masonry" and go with something according to "collapsed". PPS: Would Flexbox become obsolete at some point? Maybe, and I think I wouldn't mind. Already now, it is possible to replace many or most Flexbox Layouts with CSS Grids. Flexbox might just be more convenient - be it for the syntax or the habit. One Flexbox layout I believe is not possible with CSS Grids could be wrapping lines with stretching items. I have a feeling that masonry grids could be able to accomplish that in some way. |
I initially preferred having masonry separated from grid. However, after reading @jensimmons' post, I must acknowledge that The only way, |
I support "Just use Grid". Things are as confusing as they are right now with flex and grid sometimes not knowing which properties I should use to adjust layouts. You have also decided on the To me the This also means that the name of this "UX pattern" is bleeding into the implementation of the browser, what if people grow tired of this name and rebrand it some years in the future? |
I’m going to be blunt because this feels over-intellectualized: not everyone needs to learn CSS or programming, but we definitely don’t need more syntax clutter. Developers still struggle with flexbox, and grid isn’t as widely adopted as it should be. Meanwhile, Chrome keeps rolling out new features that most people probably barely use or have time to learn. Honestly, I’d rather see a pause on new features so tutorials can catch up. Just make this a grid property—developers can’t keep up with endless new syntax. If it works 90% of the time, throw a console warning for edge cases and call it a day. Just my two cents to speak for web devs who aren't active in GitHub discussions. That said, it’s a great idea overall. |
I'm going with webkit proposal. Masonry is a grid variant, but a grid nonetheless. I see above a comnent saying that Masonry and a fixed grid are as distinct as Grid and Flexbox, but I disagree on that. Flex is used for layout and alignment, even in a single block element, so the distinction between that and a grid is pretty clear cut. The lack of a fallback in the chrome proposal for adding a entire new display property is too limiting, wheras falling back to a regular grid is sufficient to not break any layouts. |
Strong pros and cons for both sides. Maybe this just means we're not ready yet for first-class masonry support in CSS. |
I vote for the webkit proposal. For me, like most others here, masonry is a grid. Additionally, I don't like the mansonry layout and would love to have an option in the browser to turn it off - this is likelier to happen if the layout is grid-based. |
Conceptually, I kinda take issue with the statement that a masonry layout is a type of grid layout. In my opinion, a grid layout is defined by the presence of both columns and rows, creating a uniform, grid-like structure with consistent alignment in both directions. In contrast, a masonry layout is primarily column-based, with items organized into columns but not constrained by row alignment. For this reason, my vote is for |
I support the webkit proposal (just use grid), for all the reasons stated above especially progressive enhancement. I also really like the mental model of masonry just being a collapsed grid axis. |
I support the Grid syntax. |
What would need to happen to make us 'ready'? |
I'll keep it simple. |
Use of A simple example with three blocks: text, button and image. On desktop the button is positioned above the bottom edge of the image, so using On mobile the image is placed between the text and button, and there’s no simple way to move a block from one column to another. One approach is to use
New Masonry Layout: .masonry {
display: masonry;
masonry-template-tracks: 50% 1fr;
@media (width <= 992px) {
display: block;
}
} Just Use Grid: .just-use-grid {
display: grid;
grid-template-rows: masonry;
grid-template-columns: 50% 1fr;
@media (width <= 992px) {
display: block;
}
} |
For me I read articles from the WebKit and Chrome teams, as well as several blog posts. Main arguments for Just Use Grid:
Source Help us choose the final syntax for Masonry in CSS; Extensibility The idea of using a single mechanism to create any layout is appealing. At the same time if the Just Use Grid approach is implemented there would be many properties and values valid only for
Source Should masonry be part of CSS grid?; If the new syntax is supported now, how we should use it? Article then provides examples showing that implementing progressive enhancement for the New Masonry Layout requires more styles and the use of Over time support for
Source Should masonry be part of CSS grid?; Responsive design The potential convenience of changing a layout at breakpoints seems like a strong argument for Just Use Grid. However I haven't seen examples showing in practice that Just Use Grid is better in this case. On this matter I agree with @astearns, in this comment, a comparison of two style examples is shown, and for me changing a layout at breakpoints using the New Masonry Layout looks clearer. At the same time overriding the direction in Just Use Grid is inconvenient, if I understand correctly: .just-use-grid {
display: grid;
grid-template-rows: masonry;
}
.just-use-gridy--modificator {
grid-template-rows: unset;
grid-template-columns: masonry;
} New Masonry Layout: .masonry {
display: masonry;
}
.masonry {
masonry-direction: row;
} |
I’ve been following the discussion here, and I think an important guiding principle is to avoid prioritizing short-term issues over long-term maintainability and usability. While baking masonry into the grid spec would indeed help with progressive enhancement, that challenge is temporary. As browser support catches up, the progressive enhancement issue fades, but the learning complexity and configuration burden would remain. Adding |
I support the Chrome team's proposal, as masonry is distinct enough from grid layouts to justify its own Keeping masonry separate will help avoid further complicating the grid syntax. Having separate mental model is also important and I think separate While the lack of a fallback to grid is a limitation, it may not be very effective anyway. Projects that require wider browser support are likely to use a more universal JavaScript approach. |
After going through some articles |
I'm leaning towards Furthermore, grid already has overlap with flex, so features overlapping with each other is not unheard of. So I think what it comes down to: do we want to pack features together to create a single powerful feature, or multiple simple features tailored to their own use-case. Also, progressive enhancement is still possible by providing multiple display properties, where |
Leaning towards the grid integrated approach, mainly due to the reuse of properties, as described in Webkit's blog, making it easier to learn and remember in my opinion.
However, just like we did with gap, it should always be possible to retroactively merge properties in a shorthand alias when masonry had some time to grow in the real world and we have a better understanding on the overlaps and differences. Yet splitting masonry to their own display retroactively is less feasible. So no strong opinion from my side, but hope the concerns about having separate properties for different contexts can be addressed with shorthand aliases in the future no matter the approach we choose now. |
Grid-Integrated syntax vs Grid-Independent syntax: Which one and why? What use cases are you excited about, and how do they map to the different syntaxes? Do you have examples? Have you written an article about it?
Read these articles for context:
The text was updated successfully, but these errors were encountered: