Why are Grid container & item the same component?
See original GitHub issueAs you all know, the grid component consists of two parts - one with the container
prop which is the container for grid items with the item
prop.
My question is, why?
It makes the code messier, it makes the docs harder to understand and to read the API methods, and the most important thing is that it’s combining two elements that are separate into one element. That’s like making Card’s CardContent
and CardAction into <Card actions>
, <Card content>
and <Card container>
.
I don’t see who benefits from Grid being one component with two different behaviours.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Why are Grid container & item the same component? #8013
As you all know, the grid component consists of two parts - one with the container prop which is the container for grid...
Read more >Understanding CSS Grid: Creating A Grid Container
This initial article will cover what happens when you create a grid container and the various properties that you can use on the...
Read more >Guide to the MUI grid system - LogRocket Blog
Under the hood, the Grid component uses Flexbox properties for greater flexibility. There are two types of grid components, container and item ....
Read more >React Grid component - Material UI - MUI
The container and item props are two independent booleans ; they can be combined to allow a Grid component to be both a...
Read more >Relationship of grid layout to other layout methods - CSS
This is because when you wrap flex items, each new row (or column when working by column) is an independent flex line in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This has always made me curious, but your explanation makes sense.
My experience so far tells me that the average use case doesn’t mix
container
anditem
props. With that in mind, there could be an easy “best-of-both-worlds” approach. MUI could provide named components that just wrapGrid
. Something like:Thoughts? If you think it’s a decent idea, I’d be happy to make the PR. The docs would need to be updated as well in order to add clarification. Maybe that would be a good time to add an example of a layout using both
container
anditem
.Thanks @oliviertassinari! Would it be appropriate to reopen this issue?