Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center CardHeader title in Material-UI?

How can I place title center on CardHeader (Material-UI)?

I am using Material-UI v0.18.7

Here is my code. I tried with textAlign: 'center' to titleStyle prop but that doesn't work.

const myTheme = {
   cardHeaderStylePref:{
      background: 'linear-gradient(to right bottom, #430089, #82ffa1)',
      color: config.actualWhite,
      height: 30,
      padding: 0
    }
}
<Card>
     <CardHeader
            title={this.props.prefName}
            style={myTheme.cardHeaderStylePref}
            subtitleColor={myTheme.color}
            titleColor={myTheme.color}
            titleStyle={{textAlign: 'center'}}
      >
      </CardHeader>
      <CardText>
            Sample text
      </CardText>
  </Card>
like image 938
Hemadri Dasari Avatar asked Feb 18 '18 06:02

Hemadri Dasari


2 Answers

Use css style textAlign to move title center

style={{ textAlign: 'center' }}
like image 176
Sachin Singh Avatar answered Nov 11 '22 11:11

Sachin Singh


Instead of doing inline styling, passing a class name should be a good option.

<CardHeader title="Subscribe" className={classes.heading} />
like image 27
Jasbir Rana Avatar answered Nov 11 '22 13:11

Jasbir Rana