Reputation: 535
I am using dialog from material ui with react js and want to increase the width of it. I know there is a prop called maxWidth
and I have used it. It only increases width upto 900px (when maxWidth="lg"
). I know there is a fullScreen
prop in which the dialog takes the entire screen. What I want is not to take the entire screen but I want to have more width than 900px. Can someone help me?
Upvotes: 1
Views: 984
Reputation: 488
Material Ui has a very large amount of ways in order to customize their components, I may suggest you to read the documentation about it: How to customize
When it's about a single component it could be easier for you to use the sx prop
For instance as written in the documentation:
<Slider
defaultValue={30}
sx={{
width: 300,
color: 'success.main',
}}
/>
Upvotes: 0
Reputation: 535
Figured it out...
You have to import makeStyles
from material-ui/core
and override some material styling.
This is dialog shared component code.
import React from 'react';
//Material UI Components
import {
Dialog,
DialogContent
} from '@material-ui/core';
//Material UI Styling
import {
makeStyles
} from '@material-ui/core/styles';
const useStyles = makeStyles({
root: {
".MuiDialogContent-root": {
padding: "0px 24px 8px 24px !important"
},
"& .MuiDialog-paperWidthLg": {
maxWidth: "none !important"
},
"& .MuiDialog-paper": {
margin: 0
},
"& .MuiDialogTitle-root": {
padding: "4px !important"
}
},
content: {
"&:first-child": {
paddingTop: "12px"
}
}
});
export default function PopUp(props) {
const {
children,
openPopup,
setOpenPopup,
} = props;
const classes = useStyles();
const handleClose = () => {
setOpenPopup(false);
};
return (
<
Dialog className = {
classes.root
}
onClose = {
handleClose
}
open = {
openPopup
}
maxWidth = "lg" >
<
DialogContent className = {
classes.content
} > {
children
} <
/DialogContent>
<
/Dialog>
)
}
Upvotes: 1