Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To add a custom button color in Angular Material design, follow these steps:

  1. Choose the color you want to use for your custom button.
  2. Open your project in the IDE of your choice.
  3. Navigate to the file where you want to add the custom button color.
  4. Import the MatButtonModule from the @angular/material package by adding the following code at the top of your file:
import { MatButtonModule } from '@angular/material/button';
  1. Add the color to your application's styles.scss file by adding the following code:
@import '~@angular/material/theming';

$custom-theme: mat-light-theme($color: (
  primary: yourColor,
));

@include angular-material-theme($custom-theme);
  1. Replace yourColor with the color you want to use for the button.
  2. Add the button to your HTML file and set the color attribute to yourColor.
<button mat-button color="yourColor">Custom button color</button>
  1. Save your changes and run your application to see the custom button color in action.