user12094588
user12094588

Reputation: 321

Angular material dark theme

Why when I set a dark theme does the background itself remain white? Do I need to install css black background myself? Or can fix this somehow?

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

Upvotes: 1

Views: 881

Answers (1)

Edric
Edric

Reputation: 26750

This is because you need to add the mat-app-background class to your document's body element if you're not using a sidenav container, as documented in the guide for theming:

Finally, if your app's content is not placed inside of a mat-sidenav-container element, you need to add the mat-app-background class to your wrapper element (for example the body). This ensures that the proper theme background is applied to your page. - Theming your Angular Material app > Using a prebuilt theme

For example:

<body class="mat-app-background">
  <app-root>Loading...</app-root>
</body>
<!-- ... -->

Upvotes: 2

Related Questions