Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
mui v5 styled Dialog not accepting styled width

I have mui v5 dialog that I am not able to set its width using style() component.

import {
  Dialog,
  DialogContent,
  DialogTitle,
  Paper,
  Typography,
} from "@mui/material";
import { Close } from "@mui/icons-material";
import { styled } from "@mui/material/styles";
import ActionButton from "./ActionButton";

import React from "react";

const StyledDialog = styled(Dialog)(({ theme }) => ({
  fullWidth: true, // it's not taking effect
  maxWidth: "lg",  // it's not taking effect
  padding: theme.spacing(2),
  position: "absolute",
  top: theme.spacing(5),
  "& MuiDialog-paper": {
    padding: theme.spacing(2),
    position: "absolute",
    top: theme.spacing(5),
  },
  "& .MuiTypography-h6": {
    paddingRight: "0px",
  },
}));

export default function Popup(props) {
  const { title, children, openPopup, setOpenPopup } = props;
  return (
    <StyledDialog open={openPopup} onClose={() => setOpenPopup(false)}>
      <DialogTitle>
        <div style={{ display: "flex" }}>
          <Typography variant="h6" component="div" style={{ flexGrow: 1 }}>
            {title}
          </Typography>
          <ActionButton
            color="secondary"
            onClick={() => setOpenPopup(false)}
          >
            <Close />
          </ActionButton>
        </div>
      </DialogTitle>
      <DialogContent dividers>{children}</DialogContent>
    </StyledDialog>

However, if I listed the props directly inside the it works.

<StyledDialog fullWidth="true" maxWidth="lg">

</StyledDialog>

What is the correct way of setting up the width and maxWidth.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try this on the styledDialog declaration:

const StyledDialog = styled((props) => (
    <Dialog
        fullWidth={true}
        maxWidth={'lg'}
        {...props}
    />
))(({ theme }) => ({
    // Your code to style the dialog goes here
}));

The problem on your code is that you arent passing the properties fullWidth and maxWidth to the component.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You are trying to use maxWidth: lg and fullWidth: true like css, but they are only for the Dialog API.

So you could use maxWidth in the component as an API like

<Dialog maxWidth="lg" fullWidth ... >

or you can add it as css style using theme.

const StyledDialog = styled(Dialog)(({ theme }) => ({
  maxWidth: theme.breakpoints.values.lg, // there's no styling such fullWidth
  ...
}));

You could have a look at the default theme.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda