How to center Dialog title in MUI?

Viewed 12207

How can I center the DialogTitle (MUI)? My code:

<Dialog
   open={this.state.open}
   titleStyle = {styles.Dialog}
   title='Title centered please!'
   actions={standardActions}
   onRequestClose={this.handleRequestClose}
>

  Dialog boby...
</Dialog>

title with text "Ingreso de Procedimientos" centered please

4 Answers

u can just simply use the dialog title component and add typography component in there

<DialogTitle>
  <Typography variant="h3" align="center">Centered Title</Typography>
</DialogTitle>

hope this help :))

I believe this is the shortest way in MUI v5. It is possible because DialogTitle returns a styled Typography which leverages system properties.

<DialogTitle textAlign="center">

Live Demo

Codesandbox Demo

None of the solutions work anymore. Try the following

 <DialogTitle>
    <label className={"h4 custom-flex-justify-center"}>Add New </label>
</DialogTitle>

and define custom-flex-justify-center class as follows

.custom-flex-justify-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

This works in Material UI 5 too

Related