question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[system] Allow max-width breakpoint instead of min-width

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

For now, responsive values only behaves as we’re using breakpoints.up('xx'), and there’s no way around to make it behaves like breakpoints.down('xx'). Providing a way to change this would be useful to some developers trying to add responsiveness to their app from larger screen resolution to smaller screen resolution.

Examples 🌈

/*
 * Below works same as `theme.breakpoints.up(key)`, hence previously defined padding is overriden
 */
<Paper sx={{ padding: { xs: 0 } }}>
  This box has a responsive width.
</Paper>
/*
 * So we need to add default style value to prevent overriding
 */
<Paper sx={{ padding: { xs: 0, md: 8 } }}>
  This box has a responsive width.
</Paper>

Motivation 🔦

We’re adding responsive(mobile) UI to desktop oriented design, and we found that we need to specify original style property value(if it has one) when using sx prop’s responsive values in material UI components(other than <Box />)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
m4theushwcommented, May 6, 2021

Since we removed the Hidden component in https://github.com/mui-org/material-ui/pull/26135, the migration path from the xxDown props to xx requires users to think mobile-first. I proposed to introduce support for xxDown in the sx prop to make this transition easier. My idea is the following:

  • xs, sm, md, lg, xl: same as theme.breakpoints.up, nothing to change here.
  • xsDown, smDown, mdDown, lgDown, xlDown: same as theme.breakpoints.down.

We should encourage mobile-first, but for those users who started with desktop-first (enterprise applications) and want to add some responsiveness these props could help, instead of having to do the reverse (mobile -> desktop).

@mnajdova This would not require new flags in the theme. https://github.com/mui-org/material-ui/issues/25846#issuecomment-823154868

2reactions
oliviertassinaricommented, Apr 22, 2021

Actually, it’s possible in https://tailwindcss.com/docs/breakpoints#custom-media-queries. I can’t find any similar requests on styled systems or chakra.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[system] Allow max-width breakpoint instead of min-width
Summary 💡 For now, responsive values only behaves as we're using breakpoints. up('xx') , and there's no way around to make it behaves...
Read more >
Max-Width vs. Min-Width - css
Min-width is the minimum width at which a style will START to be applied. (Have to be ordered from smallest to largest to...
Read more >
Sizing - MUI System
Max-width. The max-width property allows setting a constraint on your breakpoints. In this example, the value resolves to theme.breakpoints.values.md .
Read more >
Overview
These breakpoints are mostly based on minimum viewport widths and allow us to scale up elements as the viewport changes. Bootstrap primarily uses...
Read more >
Approaches to Media Queries in Sass
A first step would be to store that breakpoint in a variable and use it ... You can give it a number and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found