Angular Material Theme Calculate Primary Color Base On Mat Color
I am building an application but i want to keep a consistent color scheme that can be changed with settings so im using material 2 with angular 2 but i am not sure how to get the color scheme on.
Angular material theme calculate primary color base on mat color. The next thing we need to do is to generate color palettes which can then be composed to an actual theme. And if we want to update default theme colors add a theme scss file in the project src folder and add the following code. To generate a color palette we can use angular material s mat palette mix in. New colors for buttons can be submitted simply by using the mat prefix on our custom color class.
The above files gets updated on adding angular material. Later this information is passed to mat light theme to override the primary and accent color definitions. Your custom theme. What you shouldn t do.
It s very easy to create a custom angular material theme. I got some idea from this official doc. Defining a theme in angular material is extremely simple all we need to do is to create a theme file select three color palettes for the main theme colors primary accent. Anatomy of a theme.
Mat light theme acts as a base theme for our application you can also try mat dark theme and check the results. This will allow you to specify primary accent and warning colors that will be used on angular material components. Finally we pass these customized theme to angular material theme function which does rest of the job. Mat palette takes a base palette yes that s another palette more on that in a second and returns a new palette that comes with material specific hue color values for light.
I located default theme scss from node modules angular2 material.