mui / mui/material-ui

Use @container instead of @media query for Grid

Open
#34,483 5 comments 15 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component: Grid scope: system type: new feature
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Summary 💡

Among the latest CSS specifications is the @container query which I believe could be seamlessly integrated with the Grid component to bring truly isolated responsive component irregardless of screen size.

Examples 🌈

The top-level api for Grid could remain the exact same for backwards compatibility.

A new isolated prop could be introduced to signal the usage of @container like so:

<Grid container isolated>
  <Grid item>
    I don't care what screen size I'm in!
  </Grid>
</Grid>

I believe that in the future the prop should be set to true by default, but for the time being whoever wants to opt-in to this app-wide could override their theme's defaultProps.

Motivation 🔦

I have found myself having to keep track of where I use each component in my app.

This means that their implementation and appearance is (to some degree) dictated by where they are placed, which goes against the isolation paradigm that components are trying to solve to begin with.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Grid component and its current responsive @media-query behavior, then trace how the container and item variants are wired. Define how an opt-in isolated prop should use @container while preserving the existing API, and verify that responsiveness follows the component container rather than the viewport.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, react
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.