changing color of <md-toolbar>?

15,857

Solution 1

You can use the md-colors directive to set it to a color from your color palette. That way it'll change automatically if you pick a different theme.

<md-toolbar md-colors="::{background: '{{theme}}-primary-700'}"

Solution 2

Be more specific in your CSS selection to override. Since the below selectors are more specific, their priority will be higher than the default background color that was not getting overridden before. In this way you are avoiding the usage of !important

.md-sidenav-left .md-theme-indigo, .md-sidenav-left .nav-theme {
    background-color: #34495e;
}

CodePen Demo

Share:
15,857
daydreamer
Author by

daydreamer

Hello Viewer, Some of the places to see my work are BonsaiiLabs My Website

Updated on June 06, 2022

Comments

  • daydreamer
    daydreamer almost 2 years

    This is how my code looks like on CodePen:

    I want the background of "Sidenav Left" to be that of "Menu Items", which is represented by class as

    .nav-theme {
      background-color: #34495E
    }
    

    I tried overriding it as

    .nav-theme, .md-theme-indigo {
      background-color: #34495E
    }
    

    but that did not work, what do I need to do?

  • Jouke
    Jouke over 5 years
    backgroundColor is not working, to make it work use <md-toolbar md-colors="::{background: '{{theme}}-primary-700'}"
  • adam0101
    adam0101 over 5 years
    @Jouke, I could have sworn that I used it as I posted, but I see the documentation shows it as you have it. I'll update the answer.