Reputation: 113
How can I center the DialogTitle
(Material UI)? 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
Upvotes: 11
Views: 17920
Reputation: 672
Directly adding Typography
props to the <DialogTitle>
didn't work in my case.
I did however find in the documentation that <DialogTitle>
accepts a sx prop. Thus you can inline add styles as follows
<DialogTitle sx={{ textAlign:"center" }}>
Upvotes: 0
Reputation: 81773
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">
Upvotes: 2
Reputation: 4891
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
Upvotes: 0
Reputation: 31
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 :))
Upvotes: 3
Reputation: 9533
This works for me:
<Dialog
titleStyle={{textAlign: "center"}}
... />
Upvotes: 19