How do i change the angular material md-primary button text color?


Basically i cant for the life of me figure out how to set the text color of the buttons using angular material and anything else using the md-primary background color.

The code i am using to create the theme is

var customPrimary = {
        '50': '#7de3cf',
        '100': '#69dec8',
        '200': '#54dac0',
        '300': '#3fd5b8',
        '400': '#2dceaf',
        '500': '#28b99d',
        '600': '#23a48b',
        '700': '#1f8f79',
        '800': '#1a7a68',
        '900': '#166556',
        'A100': '#92e8d7',
        'A200': '#a7ecdf',
        'A400': '#bcf1e7',
        'A700': '#115044'

However no matter what i try i can get the text colour to be #fff unless i use css and !important which i’d like to avoid, as it means overriding several selectors.


From the docs:

angular.module('myApp', ['ngMaterial'])
.config(function($mdThemingProvider) {
  $mdThemingProvider.definePalette('amazingPaletteName', {
    '50': 'ffebee',
    'A700': 'd50000',
    'contrastDefaultColor': 'light',    // whether, by default, text (contrast)
                                        // on this palette should be dark or light
    'contrastDarkColors': ['50', '100', //hues which contrast should be 'dark' by default
     '200', '300', '400', 'A100'],
    'contrastLightColors': undefined    // could also specify this if default was 'dark'

The important thing here is the contrastDarkColors/contrastLightColors. The “contrast” color is the text (or icon) color that shows up on buttons.

I’m guessing you’ll want something like

'contrastDefaultColor': 'light',
'contrastDarkColors': ['50', '100', '200', '300', 'A100', 'A400']

Edit: if you for some reason wanted a color on a button, creating a class that has an !important is fine, e.g.

.md-button.cyan-text {
    color: cyan !important;


<md-button class="md-primary md-raised cyan-text">Hello world</md-button>

Answered By – Bryan K

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published