I want to use my company's brand colors throughout the app.
I have found this issue: AngularJS 2 - Material design - set color palette where I can build an allegedly custom theme, but it's basically just using different parts of pre-built palettes. I don't want to use Material2's predefined colors. I want my unique and special brand colors. Is there a better way (righter?) to create my own theme, than just hack around with _palette.scss
?
Do I need to make a mixin for my brand palette? If so - any guides on how to do it properly? What are the meanings of the different shades of colors (marked with numbers like: 50, 100, 200, A100, A200...)?
Any information about this area will be much appreciated!
After some research I ended up with this conclusion which solved it for me, hope it will help you too.
Step1: Create your own palettes from branding colors.
Found this awesome website where you enter your brand color, and it creates a complete palette with the different shades of that brand color: http://mcg.mbitson.com
I used this tool for both my
primary
color (which is my brand color) and theaccent
color.Step2: Create palettes in your custom theme file
here is a guide how to create such
.scss
file: https://github.com/angular/material2/blob/master/guides/theming.mdSome explanation on the code above
The numbers on the left side set the "level" of brightness. The default is 500 (which is the true shade of my brand color/accent color). So in this example, my brand color is
#5282c1
. The rest are other shades of that color (where lower numbers mean brighter shades and higher numbers mean darker shades). TheAXXX
are different shades. Not sure (yet) where they are in use. Again, a lower number means brighter and higher numbers means darker.The
contrast
sets the font color over those background colors. It's very hard (or even impossible) to calculate via CSS where the font should be bright (white) or dark (black with 0.87 opacity) so it is easily readable even to color blind people. So this is set manually and hard-coded into the palette definition. You get this also from the palette generator I linked above (although it's being outputted in the old Material1 format, and you'll have to manually convert this to Material2 format like I posted here).Set the theme to use the brand color palette as the
primary
color, and whatever you have for accent as youraccent
color.Step3: Use the theme throughout the app wherever you can
Some elements can take the theme colors, like
<md-toolbar>
,<md-input>
,<md-button>
,<md-select>
and so on. They will useprimary
by default so make sure you set the brand color palette as primary. If you want to change the color, use thecolor
directive (is it an Angular directive?).For example:
<button mat-raised-button color="accent" type="submit">Login</button>