Skip to content
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

Grid2 Doesn't use css gap? Why? #35103

Closed
2 tasks done
httpete opened this issue Nov 11, 2022 · 6 comments
Closed
2 tasks done

Grid2 Doesn't use css gap? Why? #35103

httpete opened this issue Nov 11, 2022 · 6 comments
Assignees
Labels
component: Grid The React component. support: question Community support but can be turned into an improvement

Comments

@httpete
Copy link

httpete commented Nov 11, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Summary 💡

Css Gap is the best css feature ever. I can't understand why the shiny new Mui Grid2 would choose an old hacky technique for spacing?

Can we opt into this? This is a showstopper for me.

Examples 🌈

.

Motivation 🔦

.

@httpete httpete added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 11, 2022
@oliviertassinari oliviertassinari added the component: Grid The React component. label Nov 12, 2022
@oliviertassinari
Copy link
Member

Related to #34510, #35104 (comment)

@siriwatknp
Copy link
Member

Related to #34510, #35104 (comment)

@oliviertassinari This issue is not related to those. The way we want the Grid component to work cannot be applied using CSS gap.

@httpete Here is the demo of why using gap does not work for the current API: https://codesandbox.io/s/poc-grid-gap-e1nq9l?file=/index.js

For the Grid item, you will need to know how many items are in a row, so that you can do this:

<div
  className="item"
  css={{
    width: "calc((100% - $gap * $(amount of items - 1)) / 3)",
    background: "tomato",
    color: "#fff"
  }}
>
  half
</div>

You can't mix gap with width in percentage.
image

@siriwatknp siriwatknp added support: question Community support but can be turned into an improvement and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 14, 2022
@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 15, 2022

@siriwatknp Right, great point.

So @httpete you can subscribe to #9513 for a version of the Grid that uses the CSS gap instead of the negative margin. It would need to use CSS grid, over CSS flexbox.

@httpete
Copy link
Author

httpete commented Nov 15, 2022 via email

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 15, 2022

css gap works fine with flex box, been using it for years.

@httpete True, since mid 2020, but it's not the problem.

@siriwatknp
Copy link
Member

No it wouldn’t, css gap works fine with flex box, been using it for years.

gap works with flexbox but it does not work for the Grid component API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Grid The React component. support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

3 participants