Search code examples
javascriptcssangularjsangularjs-material

Change colors for AngularJS Material in CSS?


I have tried to change the color of the text in input in AngularJS Material with CSS but somehow haven't got it to work. What am I doing wrong?

This is my input field:

<md-input-container>
        <label>Title</label>
        <input ng-model="user.title">
</md-input-container>

and this is how I have tried to change the color of the text.

<md-input-container style='color:#e52973'>
        <label>Title</label>
        <input style='color:#e52973' ng-model="user.title">
</md-input-container>

Solution

  • You need to use !important with your style attributes to override defaults.

    Also you just need to apply style on input not to md-input-container to change color of input text.

    So your current code:

    <md-input-container style='color:#e52973'>
            <label>Title</label>
            <input style='color:#e52973' ng-model="user.title">
    </md-input-container>
    

    Change to:

    <md-input-container>
            <label>Title</label>
            <input style='color:#e52973 !important' ng-model="user.title">
    </md-input-container>
    

    Working codepen example: https://codepen.io/anon/pen/VxrjEx