Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular material design - how to add custom button color?

I want to add my own custom colors, similar to "primary", "warn" etc. For example, I added a class for an orange background, but I use it as a class and not as a color attribute. It works, but the code looks a bit confusing.

<button md-raised-button         color="primary"         class="btn-w-md ml-3 orange-500-bg">           <i class="material-icons">description</i>           Deactivate </button> 

What do I need to do to add it as color="orange"?

like image 248
Shaniqwa Avatar asked Jul 17 '17 12:07

Shaniqwa


People also ask

How do you color a mat button?

To change the color of mat-button color use color property. We can change the background color to primary, accent, or warn.

How do you change the color of a button in typescript?

In the ChangeColor() function, we call another function Change2(). This function is used to change the color of the button again.

How do I change the mat toolbar color in angular materials?

The color of a <mat-toolbar> can be changed by using the color property. By default, toolbars use a neutral background color based on the current theme (light or dark). This can be changed to 'primary' , 'accent' , or 'warn' .

What is accent color in angular material?

A theme is a collection of color and typography options. Each theme includes three palettes that determine component colors: A primary palette for the color that appears most frequently throughout your application. An accent, or secondary, palette used to selectively highlight key parts of your UI.


1 Answers

You can add any color like below

 <a mat-mini-fab color="success" routerLink=".">link</a>
it generates the class with that value like 'mat-success' then create css for that class

.mat-success {      background-color: green;      color: #fff;  }
like image 105
Gopi Avatar answered Sep 26 '22 00:09

Gopi