matDialog doesn't open as dialog

@Jay Cummins' answer worked for me. (Up voted but I couldn't reply to it to add this extra information)

I found that putting the style sheet in angular.json did not trigger the auto-build.

I was playing around, trying to figure why the styles would fix the problem, I found I could add this

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

to the top of my styles.css. This triggers the rebuild and also fixes the problem.


I had the same issue in my Angular 6 app. The solution was adding a pre-built theme to styles in the angular.json file styles property.

    "styles": [
      "src/styles.scss",
      {
        "input": "node_modules/@angular/material/prebuilt-themes/purple-green.css"
      }
    ]

enter image description here


Add in style.css:

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