-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Dialog] Better mobile default margin? #16560
Comments
👋 Thanks for using Material-UI! We use the issue tracker exclusively for bug reports and feature requests, however, If you would like to link from here to your question on SO, it will help others find it. |
You might be looking for |
I am aware maxWidth is a prop. What I meant is that if you look at fullWidth Description on the same page you indicated above, So it should stretch to maxWidth which defaults to If you say it's fullWidth and then you take 48px margin on each side on a 320px wide screen, that's not really fullWidth and it looks poorly. And yes, I believe this is an actual bug. |
My bad, I believe this has been brought up before but I forgot what was spoken about cc @oliviertassinari |
@joshwooding The described behavior looks good to me. I would expect CSS overrides can solve the problem. |
So, full width is not actually full width and one has to hack it in order for it to work properly. |
On a different topic, I would propose that we reduce the default margin: diff --git a/packages/material-ui/src/Dialog/Dialog.js b/packages/material-ui/src/Dialog/Dialog.js
index 3b8dbe760..ec46b2333 100644
--- a/packages/material-ui/src/Dialog/Dialog.js
+++ b/packages/material-ui/src/Dialog/Dialog.js
@@ -50,7 +50,7 @@ export const styles = theme => ({
},
/* Styles applied to the `Paper` component. */
paper: {
- margin: 48,
+ margin: 32,
position: 'relative',
overflowY: 'auto', // Fix IE 11 issue, to remove at some point.
'@media print': {
@@ -62,7 +62,7 @@ export const styles = theme => ({
paperScrollPaper: {
display: 'flex',
flexDirection: 'column',
- maxHeight: 'calc(100% - 96px)',
+ maxHeight: 'calc(100% - 64px)',
},
/* Styles applied to the `Paper` component if `scroll="body"`. */
paperScrollBody: {
@@ -72,14 +72,14 @@ export const styles = theme => ({
},
/* Styles applied to the `Paper` component if `maxWidth=false`. */
paperWidthFalse: {
- maxWidth: 'calc(100% - 96px)',
+ maxWidth: 'calc(100% - 64px)',
},
/* Styles applied to the `Paper` component if `maxWidth="xs"`. */
paperWidthXs: {
maxWidth: Math.max(theme.breakpoints.values.xs, 444),
'&$paperScrollBody': {
- [theme.breakpoints.down(Math.max(theme.breakpoints.values.xs, 444) + 48 * 2)]: {
- maxWidth: 'calc(100% - 96px)',
+ [theme.breakpoints.down(Math.max(theme.breakpoints.values.xs, 444) + 32 * 2)]: {
+ maxWidth: 'calc(100% - 64px)',
},
},
},
@@ -87,8 +87,8 @@ export const styles = theme => ({
paperWidthSm: {
maxWidth: theme.breakpoints.values.sm,
'&$paperScrollBody': {
- [theme.breakpoints.down(theme.breakpoints.values.sm + 48 * 2)]: {
- maxWidth: 'calc(100% - 96px)',
+ [theme.breakpoints.down(theme.breakpoints.values.sm + 32 * 2)]: {
+ maxWidth: 'calc(100% - 64px)',
},
},
},
@@ -96,8 +96,8 @@ export const styles = theme => ({
paperWidthMd: {
maxWidth: theme.breakpoints.values.md,
'&$paperScrollBody': {
- [theme.breakpoints.down(theme.breakpoints.values.md + 48 * 2)]: {
- maxWidth: 'calc(100% - 96px)',
+ [theme.breakpoints.down(theme.breakpoints.values.md + 32 * 2)]: {
+ maxWidth: 'calc(100% - 64px)',
},
},
},
@@ -105,8 +105,8 @@ export const styles = theme => ({
paperWidthLg: {
maxWidth: theme.breakpoints.values.lg,
'&$paperScrollBody': {
- [theme.breakpoints.down(theme.breakpoints.values.lg + 48 * 2)]: {
- maxWidth: 'calc(100% - 96px)',
+ [theme.breakpoints.down(theme.breakpoints.values.lg + 32 * 2)]: {
+ maxWidth: 'calc(100% - 64px)',
},
},
},
@@ -114,14 +114,14 @@ export const styles = theme => ({
paperWidthXl: {
maxWidth: theme.breakpoints.values.xl,
'&$paperScrollBody': {
- [theme.breakpoints.down(theme.breakpoints.values.xl + 48 * 2)]: {
- maxWidth: 'calc(100% - 96px)',
+ [theme.breakpoints.down(theme.breakpoints.values.xl + 32 * 2)]: {
+ maxWidth: 'calc(100% - 64px)',
},
},
},
/* Styles applied to the `Paper` component if `fullWidth={true}`. */
paperFullWidth: {
- width: 'calc(100% - 96px)',
+ width: 'calc(100% - 64px)',
},
/* Styles applied to the `Paper` component if `fullScreen={true}`. */
paperFullScreen: { @BernardA Would it help in your case? |
Kind of depends what the target audience for these props are. In the CSS box model we separate width, padding and margin. So if padding or margin are greater than 0 then the width will not be equal to used horizontal space (i.e. perceived width). So for people not familiar with CSS it will indeed be confusing. Otherwise I'd say the name is fitting. We can improve documentation though and be explicit about the difference between fullWidth and fullScreen |
@eps1lon Your comment may be fine for the Illuminati, as long as technicality is concerned. Common sense may disagree with that though. But if you look at the 2 pictures I posted above and you still think that your concept of full width is fine, then I rest my case. |
As I said it's not my concept but that applied in CSS. I completely understand that it might not be intuitive for people not familiar with CSS which is why I suggested the docs improvement approach. But since this is concerned with styles, styles are implemented with CSS and by people using CSS |
In that case I'd suggest you change that property from |
If we ignore margin, yes. The current fullWidth behavior matches the width behavior in the CSS box model. fullScreen is a shorter alias for fullScreenWidthAndFullScreenHeight
Following the logic of the CSS box model you could create a dialog with arbitrary margin and call it full width, yes. It wouldn't be full screen, no. That's why we have the separate prop. How would you propose fullScreen should behave if fullWidth already uses the full screen? |
I did not propose at all that fullWidth is full screen ( height and width ), but only full screen width. It should be plain to see, pun intended, that if you have a property that is meant to be full width, but then you play around with margins so that it becomes something else completely, you are defeating the purpose. |
We have precedents for a Ok, aside from the default margin reduction, I would propose that we update the prop description: diff --git a/packages/material-ui/src/Dialog/Dialog.js b/packages/material-ui/src/Dialog/Dialog.js
index 3b8dbe760..25d30923b 100644
--- a/packages/material-ui/src/Dialog/Dialog.js
+++ b/packages/material-ui/src/Dialog/Dialog.js
@@ -290,6 +290,8 @@ Dialog.propTypes = {
fullScreen: PropTypes.bool,
/**
* If `true`, the dialog stretches to `maxWidth`.
+ *
+ * Notice that the dialog width grow is limited by the default margin.
*/
fullWidth: PropTypes.bool,
/** |
I made a dialog yesterday that looks like this on mobile. I did it by passing down this prop to the Dialog component:
Which is applying this style from jss:
It seems in line with what @BernardA is wanting. I am overriding the margin for the dialog on a smaller screen (he would want From the MUI Docs
That being said, perhaps @oliviertassinari's proposed wording update would help, too. |
@m2mathew Thanks for confirming it. So the prop description update is the preferred resolution path for this issue :). |
For our app, we found 48px margin on dialogs to be too much on the smallest screens. We added media queries to change it to 40px for max-width: 375px and 32px for even smaller. I think something like this should be the default. This caused much trouble for us as, for example, our login buttons were too wide to fit in a dialog on a screen of size 320px because of the large margin. |
@jahooma I think that we should reduce the margin on mobile devices, I agree. Do you want to work on a pull request? We could start from #16560 (comment) :) |
dialog: {
[theme.breakpoints.down('sm')]: {
"& .MuiDialog-container .MuiDialog-paper": {
margin: "24px 0px",
borderRadius: 0
},
}
} |
Can you plaese tell me where should I put this code? |
Thank you! |
When I set the dialog as fullWidth={true} I expect it to take whole screen up to maxWidth.
On mobile, width is calculated as
width: calc(100% - 96px);
, the 96px coming from the rule just belowmargin: 48px;
.So, it actually does not take full width and it just looks bad.
Expected Behavior 🤔
Current Behavior 😯
It takes width minus margin, which in the case is 48px at each side ( well, top and bottom as well, but that does not matter)
Steps to Reproduce 🕹
Link: to sandbox
Context 🔦
Just trying to have a full width feature to work properly. I did try to change the
paperFullWidth:
property, but that ends up changing the root element.Your Environment 🌎
The text was updated successfully, but these errors were encountered: