Halt
Halt

Reputation: 1135

Can't style material-ui with its own props

I'm using the material-ui and try to style the background-color of the RaisedButton, using one of its props called backgroundColor:

import React, {Component} from 'react';
import RaisedButton from 'material-ui/lib/raised-button';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Home.scss';

class Home extends Component {
    render() {
        return (
            <div>
                <h1 className={s.h1}>Pomodoro Tech</h1>
                <div className={s.imgContain}>
                    <img src={require('./pom.png')} width="100%" height="100%"/>
                </div>
                <div>
                    <RaisedButton
                        label="Login"
                        secondary={true}
                        backgroundColor="#77CA2D"
                    />
                    <RaisedButton
                        backgroundColor="#77CA2D"
                        label="About"
                    />
                </div>
            </div>
        );
    }
}

export default withStyles(Home, s);

But that property never makes any differences.

The version of the material-ui I am using is 0.15.0-alpha.1, according to the result of npm list --depth=0 command.

Before I ask this question I've done some search, but can't figure out what the problem is.

Upvotes: 1

Views: 1075

Answers (2)

fjaye
fjaye

Reputation: 93

Make sure you don't include primary={true}; it will ignore your backgroundColor otherwise. See mine below:

<RaisedButton
  label={stepIndex === 2 ? 'Finish' : 'Next'}
  disableTouchRipple={true}
  disableFocusRipple={true}
  onClick={this.handleNext}
  backgroundColor={teal400}
/>

Upvotes: 0

Mohammad Arif
Mohammad Arif

Reputation: 7581

It's working for me, have been using material-ui v0.14.4, may be it's been breaking in 0.15.0-alpha.1

Please paste the working example on JSBin or somewhere to debug it further.

Upvotes: 0

Related Questions