DEV Community

Haruka Kato
Haruka Kato

Posted on

text-align:center doesn't work for button

I was trying to place a button in the center and I could not apply text-align:center or margin: 0 auto and I found out that

button:{
  textAlign: 'center',
},

 <div className={classes.button}>
     <Button variant="contained" color="primary"   
    disableElevation className={classes.button}>
       Confirm
     </Button>
 </div>

Enter fullscreen mode Exit fullscreen mode

You can enclose Button tag with div and apply text-align:center to div element!

Hope this helps!

Top comments (2)

Collapse
 
alohci profile image
Nicholas Stimpson

margin: 0 auto will work if you also make the button display:block.

Collapse
 
harukakato35 profile image
Haruka Kato

ohhh I see I will try next time thank you!