11

So it looks I can change the background-color of an empty md-checkbox by doing :

md-checkbox .md-icon {
background: red;
}

But I can't manage to change the background of a checked md-checkbox. I tried to play with :checked, ::before, ::after... But didn't succeed.

How should I proceed ?

G. Tranter
  • 16,766
  • 1
  • 48
  • 68
Ellone
  • 3,644
  • 12
  • 40
  • 72

2 Answers2

10

You need to use theme class as well as md-checked class combination in order to define selector with higher specificity. For example:

md-checkbox .md-icon {
    background: red;
}
md-checkbox.md-default-theme.md-checked .md-icon {
    background: orange;
}

And of course, avoid using !important, this is a sign that something is wrong with your styles.

dfsq
  • 191,768
  • 25
  • 236
  • 258
  • Thanks, is there also a way to change the 'checking icon' color inside the box to make it suit the new color better ? – Ellone Sep 03 '15 at 13:49
  • 2
    Try this rule: `md-checkbox.md-default-theme.md-checked .md-icon:after { border-color: green; }`. Or more generic: `md-checkbox.md-default-theme.md-checked .md-icon:after, md-checkbox.md-default-theme:not([disabled]).md-checked .md-icon:after { border-color: green; }`. – dfsq Sep 03 '15 at 13:57
6

in new version added underscore ._md-icon:

md-checkbox.md-checked ._md-icon {
         background-color: white;
}
Stav Bodik
  • 2,018
  • 3
  • 18
  • 25