tilly
tilly

Reputation: 2610

App can't load Angular material theme

I want to use Angular Material in my MEAN stack app, but I get the following 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

In my Angular CLI apps I manage to work with Angular material, but with this app I just can't seem to make it work. It is probably because of the structure of the app:

enter image description here

As you can see on the image I tried with the @import statement. On the homepage I put a checkbox Material item (here named jjjjjj), but as you can see it doesn't have the theme so it doesn't look good.

enter image description here

Upvotes: 1

Views: 4609

Answers (2)

RobotNerd
RobotNerd

Reputation: 2658

I had the same problem, and it was because I was trying to import the material theme into the css file of one of my components. Moving the import statement to the top-level styles.css file worked.

  • @angular/core 6.0.0
  • @angular/material 6.4.1

Add the line below to the file src/styles.css:

@import "@angular/material/prebuilt-themes/indigo-pink.css";

Upvotes: 2

nour
nour

Reputation: 568

I had the same problem and for me it works try to add this line instead:

@import "~@angular/material/prebuilt-themes/indigo-pink.css";

you can choose here the theme you want to apply Material theme

Upvotes: 3

Related Questions