0
votes

Can't install Angular Material pre-built theme. Installed all components, linked a .css file. Still have save error:

Could not find Angular Material core theme. Most Material components may not work as expected. For more info refer to the theming guide: https://material.angular.io/guide/theming

Added to .css: @import "~@angular/material/prebuilt-themes/indigo-pink.css"

Installed all components @angular/material @angular/cdk @angular/animations and imported all modules: BrowserAnimationsModule, MatButtonModule, MatCheckboxModule.

Expecting to see slick material design.

1
Where did you import the theme file? - IvanS95
@Lbovsky can share minimal code on stackblitz? - Abhishek
@IvanS95 to the app.component.css. - Albovsky
You should import it in styles.css not on the component's css, alternatively you can link it in index.html with <link href="node_modules/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet"> in the head tag - IvanS95
@IvanS95 thanks a lot. I knew a solution is simple, now it works:) - Albovsky

1 Answers

1
votes

The theme file should be imported in the global styles.css file of your application, according to Angular Material Docs:

If you're using Angular CLI, this is as simple as including one line in your styles.css file:

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

Alternatively, you can just reference the file directly. This would look something like:

<link href="node_modules/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet">