mui / mui/material-ui

Enforce specific breakpoint on Component Level

Open
#36,226 1 comment 1 reaction 1 assignee View on GitHub

@siriwatknp is already working on this.

Since Feb 17, 2023.

component: Grid customization: css 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 💡

This issue proposes adding a new feature to the project that would allow us to override the default breakpoint for a specific component. Currently, the project uses a set of breakpoints to determine the layout and responsiveness of components, but there are cases where a we need to use a different breakpoint for a specific component. This feature would give us more flexibility and control over the design of their components.

Examples 🌈
export const GridExample: FC<{ breakpoint: Breakpoint }> = ({ breakpoint }) => {  // assume breakpoint=sm
        // grid should use "sm" breakpoint even if the screen is "xl"
	<Grid
		container
                breakpoint={breakpoint}
		columns={{
			sx: 4,
			sm: 8,
			md: 12,
			lg: 10,
			xl: 10,
		}}
	>
		<Grid item width={1} xs={4} sm={8} md={6} lg={4} xl={4}>
			<p>...</p>
		</Grid>
	</Grid>;
};
Motivation 🔦

Currently, the Grid selects the breakpoint based on screen size, but this approach has its limitations. Implementing the suggested feature would increase the flexibility of the Grid.

Ideas

There are alternative approaches to the suggested feature, such as creating a Container component that extends the current theme object and enforces a specific breakpoint for its child components. This could be achieved by passing the desired breakpoint as a prop to the Container, which would then apply the breakpoint to all of its child components. This approach could offer greater flexibility in terms of controlling the layout and responsiveness of components, and may be a useful alternative to implementing a feature that allows for overriding the default breakpoint at the component level.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.