question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng add @angular/material does not add styles to the app

See original GitHub issue

Bug, feature request, or proposal:

When running ng add @angular/material on a new Angular app generated with Angular CLI v6 the styles are not applied.

What is the expected behavior?

The Angular Material stylesheet ‘indigo-pink’ gets applied.

What is the current behavior?

The stylesheet does not get applied.

Also, the schematic seems to update node_modules/@angular/material/prebuilt-themes/indigo-pink.css instead of src/styles.{ext} by adding body { margin: 0; }.

 ng add @angular/material
Installing packages for tooling via npm.
npm WARN @angular/material@6.0.0 requires a peer of @angular/cdk@6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ @angular/material@6.0.0
added 1 package in 16.059s
Installed packages for tooling via npm.
UPDATE package.json (1390 bytes)
UPDATE angular.json (3766 bytes)
UPDATE src/app/app.module.ts (423 bytes)
UPDATE src/index.html (483 bytes)
UPDATE node_modules/@angular/material/prebuilt-themes/indigo-pink.css (56678 bytes)

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV

What is the use-case or motivation for changing an existing behavior?

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.0
Node: 10.0.0
OS: linux x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, material, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@angular/cdk                      <error>
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0
 npm show @angular/material

{ name: '@angular/material',
  description: 'Angular Material',
  'dist-tags': { latest: '6.0.0', next: '6.0.0' },

Is there anything else we should know?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
jerryorta-devcommented, May 5, 2018

The output can be a little misleading, but the styles are added to the angular.json file as

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

The cli will process the theme with your styles when served / built.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 9, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Material styles not being applied correctly
In my case, I created an empty workspace, added a library, and then added an app project. I went back and ran ng...
Read more >
Customizing component styles | Angular Material
While Angular Material does not support defining custom styles or CSS overrides on components' internal elements, you might choose to do this anyway....
Read more >
3 Correct Ways To Overwrite Angular Material Styles
More specific styles will take precedence over less specific styles. So in our case, we have to add more specificity to overwrite our...
Read more >
Add Angular 13 Material
Each Angular Material component has a separate module that you need to import before you can use the component. Open the src/app/app.module.ts file...
Read more >
Angular :host, :host-context, ::ng-deep - The Complete Guide
In order to cover each feature, we will be adding the multiple examples to ... We cannot do that using styles inside its...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found