אVי
אVי

Reputation: 1973

Angular Material styles not applied

I'm running node 12.18.2 I installed the latest version of Angular CLI (10.0.2)

I created a new app (ng new APP_NAME); I installed angular material (ng add @angular/material)

Then I try to display some buttons an this is what i get:

enter image description here

This is my configuration:

package.json:

    {
    "dependencies": {
      "@angular/animations": "~10.0.3",
      "@angular/cdk": "^10.0.1",
      "@angular/common": "~10.0.3",
      "@angular/compiler": "~10.0.3",
      "@angular/core": "~10.0.3",
      "@angular/forms": "~10.0.3",
      "@angular/material": "^10.0.1",
      "@angular/platform-browser": "~10.0.3",
      "@angular/platform-browser-dynamic": "~10.0.3",
      "@angular/router": "~10.0.3",
      "rxjs": "~6.5.5",
      "tslib": "^2.0.0",
      "zone.js": "~0.10.3"
      },
    "devDependencies": {
      "@angular-devkit/build-angular": "~0.1000.2", 
      "@angular/cli": "~10.0.2",
      "@angular/compiler-cli": "~10.0.3",
      "@types/node": "^12.11.1",
      "@types/jasmine": "~3.5.0",
      "@types/jasminewd2": "~2.0.3",
      "codelyzer": "^6.0.0",
      "jasmine-core": "~3.5.0",
      "jasmine-spec-reporter": "~5.0.0",
      "karma": "~5.0.0",
      "karma-chrome-launcher": "~3.1.0",
      "karma-coverage-istanbul-reporter": "~3.0.2",
      "karma-jasmine": "~3.3.0",
      "karma-jasmine-html-reporter": "^1.5.0",
      "protractor": "~7.0.0",
      "ts-node": "~8.3.0",
      "tslint": "~6.1.0",
      "typescript": "~3.9.5"
     }

angular.json:

"styles": [
             "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
             "src/styles.scss"
           ],

i added this in the styles.scss file:

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

I'm expecting the buttons to look like this: enter image description here What am I missing?

Upvotes: 1

Views: 3901

Answers (1)

kasptom
kasptom

Reputation: 2458

Here is the Stackblitz with the working styles. Maybe you have to add the MatDividerModule, MatIconModule, MatButtonModule to your module.

@NgModule({
  imports:      [ BrowserModule, FormsModule, MatDividerModule, MatIconModule, MatButtonModule ],
  declarations: [ AppComponent, HelloComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

Upvotes: 2

Related Questions