Material UI Javascript Dialog increase width

0

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?

javascript material-ui reactjs
2021-11-24 06:22:02
2

1

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>

  )
}

2021-11-24 08:59:48
0

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',
  }}
/>
2021-11-24 09:11:51

i tried that. it only increases width upto 900px. i need more width than that
Shakya Karunathilake

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................