Angular 2+ theme button colors not working

All you forgot here was to import MatButtonModule like:

import {MatButtonModule} from '@angular/material/button';

and then off-course in import array

imports: [ BrowserModule, FormsModule, MatButtonModule ]

in your app.module.ts since you have single module here.

Also, be sure to import a theme too in styles.css

@import '@angular/material/prebuilt-themes/deeppurple-amber.css';

Here's stackblitz


I added material to my project(Angular 9) by using ng add @angular/material and faced the same problem.

To fix it, I add to add below the dependency manually to the package.json:

"@angular/material-moment-adapter": "^9.2.2"

Hope this will help anyone facing issue with newer versions or using ng add command.

Tags:

Themes

Angular