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

[material-ui] Dialog Title overrides the Dialog Content padding #27851

Open
ghost opened this issue Aug 19, 2021 · 18 comments
Open

[material-ui] Dialog Title overrides the Dialog Content padding #27851

ghost opened this issue Aug 19, 2021 · 18 comments
Assignees
Labels
component: dialog This is the name of the generic UI component, not the React module! new feature New feature or request package: material-ui Specific to @mui/material

Comments

@ghost
Copy link

ghost commented Aug 19, 2021

Title gets rid of the top padding on Dialog Content and it gets overridden by:

.MuiDialogTitle-root+.css-141nu3b-MuiDialogContent-root {
padding-top: 0;
}

This is on "@material-ui/core": "^5.0.0-beta.1".

This is an issue if you have the whole title background a different color than the content. Content will bump right up to it.

Example:

https://codesandbox.io/s/hopeful-fermi-0v850?file=/src/App.js:514-515

#26795

@ghost ghost added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 19, 2021
@AlvesJorge
Copy link
Contributor

Hi Chase,
Try using style instead of sx to set the paddingTop.
Sandbox example
Don't know why this happens but seems sometimes when mui is stubborn , using style instead of sx works.There's probably a reason out there not to do this, but since I don't know what it is I can't tell you not to do it haha.
Cheers

@eps1lon
Copy link
Member

eps1lon commented Aug 23, 2021

You codesandbox doesn't include any styles related to padding. Could you clarify what the issue is?

Or are you just suggesting that the content should have padding as well?

@eps1lon eps1lon added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 23, 2021
@ghost
Copy link
Author

ghost commented Aug 23, 2021

@eps1lon I am suggesting content should have padding as well as a default. That way it can be modified in a theme. For example: this doesn't work and gets overridden and paddingTop gets set to 0

    MuiDialogContent: {
      styleOverrides: {
        root: {
          padding: "4.0rem",
        },
      },
    },
    

@karpolan
Copy link

karpolan commented Oct 3, 2021

Got same issue

image

@ghost
Copy link
Author

ghost commented Oct 3, 2021

Got same issue

image

There is a work around. Add “dividers” prop to DialogContent and style the dividers to the color of the dialog background. This will add your padding like you expect

@karpolan
Copy link

karpolan commented Oct 4, 2021

Got same issue
image

There is a work around. Add “dividers” prop to DialogContent and style the dividers to the color of the dialog background. This will add your padding like you expect

This dialog was working for years, but new MUI overrides the styling I temporary wrap content with <Box pt={1}>...

@Shrammer1
Copy link

I have this same issue:

image

My Theme:

getMuiTheme = () => createTheme({	
		
		components:{
			MuiDialogContent: {
				styleOverrides: {
				  root: {
					padding: '10px',
				  },
				},
			},
			MuiDialogTitle:{
				styleOverrides: {
					root: {
						
					},
				  },
			},
		},
		button:{
			backgroundColor:"white",
			border: "0px"
		},
	  })

Dev tools CSS:

image

Temporary work around is to apply style directly to dialog content component:
<DialogContent style={{paddingTop: '10px'}}> <FormControl fullWidth> {transferUserList} </FormControl> </DialogContent>

@VinceVachon
Copy link

Why was this closed? Has it been fixed?

@limboguard
Copy link

I am getting the same issue, was this closed because it was fixed?

@mbrookes
Copy link
Member

It was closed because it had been left as incomplete for a few months, where in fact @chaserda had provided additional information, but the incomplete status hadn't been removed. Moving back to "needs triage"

@mbrookes mbrookes added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Mar 30, 2022
@bradstdev
Copy link

I have numerous dialogs in my app, so I did a hacky option, which I would rather remove when this is fixed:

      MuiDialogContent: {
        styleOverrides: {
          root: {
            padding: `${theme.spacing(1.5, 2.5)}!important`,
          },
        },
      },

@mnajdova mnajdova self-assigned this May 23, 2022
@mnajdova mnajdova added new feature New feature or request component: dialog This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 25, 2022
@jamestalton
Copy link

ran into this issue

@aweibell
Copy link

Also struggled a long time with this. Appears to me as a bug that one need to override with !important to get any padding for the DialogContent.

@mnajdova mnajdova added this to the v6 milestone Mar 22, 2023
@leachtucker
Copy link

Just running into this issue now after migrating from MUI V4 to V5

@mohd676
Copy link

mohd676 commented Jul 15, 2023

Document work around

add document.body.classList.add('fix_body_padding_open'); on top of your react hooks component

css
.fix_body_padding{
&_open{
padding-right: 0px !important;
}
}

then remove it onClose

document.body.classList.remove('fix_body_padding_open');

@iribeiro-workwave
Copy link

Can be overwritten like this as well.

<DialogContent sx={{ '.MuiDialogContent-root&.MuiDialogContent-root': { pt: 1 } }}>

@huanqizh
Copy link

I resolve this problem with this way:

MuiDialog: {
        styleOverrides: {
            paper: {
                "& > div.MuiDialogContent-root": { paddingTop: "20px" }
            }
        }
    }

Use the more higher poiority css selector to cover it in createTheme.

@danilo-leal danilo-leal added the package: material-ui Specific to @mui/material label Dec 1, 2023
@danilo-leal danilo-leal changed the title Dialog Title overrides Dialog Content Padding. [material-ui] Dialog Title overrides the Dialog Content padding Dec 1, 2023
@DiegoAndai DiegoAndai removed the v5.x label Dec 7, 2023
@jsduffy
Copy link

jsduffy commented Apr 3, 2024

Same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: dialog This is the name of the generic UI component, not the React module! new feature New feature or request package: material-ui Specific to @mui/material
Projects
Status: Backlog
Development

No branches or pull requests