@angular/material styles in a single stylesheet
I want to move all the styles into a single stylesheet, no individual component styles. I can control my styles, however when I include @angular/material components, they are added as individual style tags:

I have a single styles.scss file, which already includes the material designs according to the docu.
// Include the default theme styles.
@include angular-material-theme($candy-app-theme);
How can I also add all the components into the single stylesheet?
Edit: this is how the @angular/material modules are added:
import NgModule from '@angular/core';
import
MatButtonModule,
MatGridListModule,
MatIconModule,
MatListModule,
MatSidenavModule,
MatToolbarModule,
from '@angular/material';
@NgModule(
exports: [
MatButtonModule,
MatGridListModule,
MatIconModule,
MatListModule,
MatSidenavModule,
MatToolbarModule,
]
)
export class MaterialModule
angular angular-material
|
show 2 more comments
I want to move all the styles into a single stylesheet, no individual component styles. I can control my styles, however when I include @angular/material components, they are added as individual style tags:

I have a single styles.scss file, which already includes the material designs according to the docu.
// Include the default theme styles.
@include angular-material-theme($candy-app-theme);
How can I also add all the components into the single stylesheet?
Edit: this is how the @angular/material modules are added:
import NgModule from '@angular/core';
import
MatButtonModule,
MatGridListModule,
MatIconModule,
MatListModule,
MatSidenavModule,
MatToolbarModule,
from '@angular/material';
@NgModule(
exports: [
MatButtonModule,
MatGridListModule,
MatIconModule,
MatListModule,
MatSidenavModule,
MatToolbarModule,
]
)
export class MaterialModule
angular angular-material
this sounds like @import ?
– Mike
Nov 15 '18 at 12:43
Yes, the styles are imported via '@include angular-material-theme($candy-app-theme);' which should add all components to the stylesheet. However the styles are still done via adding style tags
– Stefan
Nov 15 '18 at 12:51
Besides global styles material also uses local styles throughstyleUrlslike github.com/angular/material2/blob/… So they are added as inline styles
– yurzui
Nov 15 '18 at 13:11
1
@Mike take.ms/IWhoM
– yurzui
Nov 15 '18 at 14:10
2
github.com/angular/angular-cli/issues/…
– yurzui
Nov 15 '18 at 14:22
|
show 2 more comments
I want to move all the styles into a single stylesheet, no individual component styles. I can control my styles, however when I include @angular/material components, they are added as individual style tags:

I have a single styles.scss file, which already includes the material designs according to the docu.
// Include the default theme styles.
@include angular-material-theme($candy-app-theme);
How can I also add all the components into the single stylesheet?
Edit: this is how the @angular/material modules are added:
import NgModule from '@angular/core';
import
MatButtonModule,
MatGridListModule,
MatIconModule,
MatListModule,
MatSidenavModule,
MatToolbarModule,
from '@angular/material';
@NgModule(
exports: [
MatButtonModule,
MatGridListModule,
MatIconModule,
MatListModule,
MatSidenavModule,
MatToolbarModule,
]
)
export class MaterialModule
angular angular-material
I want to move all the styles into a single stylesheet, no individual component styles. I can control my styles, however when I include @angular/material components, they are added as individual style tags:

I have a single styles.scss file, which already includes the material designs according to the docu.
// Include the default theme styles.
@include angular-material-theme($candy-app-theme);
How can I also add all the components into the single stylesheet?
Edit: this is how the @angular/material modules are added:
import NgModule from '@angular/core';
import
MatButtonModule,
MatGridListModule,
MatIconModule,
MatListModule,
MatSidenavModule,
MatToolbarModule,
from '@angular/material';
@NgModule(
exports: [
MatButtonModule,
MatGridListModule,
MatIconModule,
MatListModule,
MatSidenavModule,
MatToolbarModule,
]
)
export class MaterialModule
angular angular-material
angular angular-material
edited Nov 15 '18 at 12:54
asked Nov 12 '18 at 23:34
Stefan
9,8251057105
9,8251057105
this sounds like @import ?
– Mike
Nov 15 '18 at 12:43
Yes, the styles are imported via '@include angular-material-theme($candy-app-theme);' which should add all components to the stylesheet. However the styles are still done via adding style tags
– Stefan
Nov 15 '18 at 12:51
Besides global styles material also uses local styles throughstyleUrlslike github.com/angular/material2/blob/… So they are added as inline styles
– yurzui
Nov 15 '18 at 13:11
1
@Mike take.ms/IWhoM
– yurzui
Nov 15 '18 at 14:10
2
github.com/angular/angular-cli/issues/…
– yurzui
Nov 15 '18 at 14:22
|
show 2 more comments
this sounds like @import ?
– Mike
Nov 15 '18 at 12:43
Yes, the styles are imported via '@include angular-material-theme($candy-app-theme);' which should add all components to the stylesheet. However the styles are still done via adding style tags
– Stefan
Nov 15 '18 at 12:51
Besides global styles material also uses local styles throughstyleUrlslike github.com/angular/material2/blob/… So they are added as inline styles
– yurzui
Nov 15 '18 at 13:11
1
@Mike take.ms/IWhoM
– yurzui
Nov 15 '18 at 14:10
2
github.com/angular/angular-cli/issues/…
– yurzui
Nov 15 '18 at 14:22
this sounds like @import ?
– Mike
Nov 15 '18 at 12:43
this sounds like @import ?
– Mike
Nov 15 '18 at 12:43
Yes, the styles are imported via '@include angular-material-theme($candy-app-theme);' which should add all components to the stylesheet. However the styles are still done via adding style tags
– Stefan
Nov 15 '18 at 12:51
Yes, the styles are imported via '@include angular-material-theme($candy-app-theme);' which should add all components to the stylesheet. However the styles are still done via adding style tags
– Stefan
Nov 15 '18 at 12:51
Besides global styles material also uses local styles through
styleUrls like github.com/angular/material2/blob/… So they are added as inline styles– yurzui
Nov 15 '18 at 13:11
Besides global styles material also uses local styles through
styleUrls like github.com/angular/material2/blob/… So they are added as inline styles– yurzui
Nov 15 '18 at 13:11
1
1
@Mike take.ms/IWhoM
– yurzui
Nov 15 '18 at 14:10
@Mike take.ms/IWhoM
– yurzui
Nov 15 '18 at 14:10
2
2
github.com/angular/angular-cli/issues/…
– yurzui
Nov 15 '18 at 14:22
github.com/angular/angular-cli/issues/…
– yurzui
Nov 15 '18 at 14:22
|
show 2 more comments
1 Answer
1
active
oldest
votes
A call to the angular-material-theme() mixin will include theming only for components plus core (global) styles. Angular Material component style that is not part of theming is encapsulated and built in to the component and dynamically added to the DOM. There is no way to automatically include those styles in a single stylesheet. Even if you could do that, it is possible that everything might not work properly, plus you would also need to turn off the style tags inserted into the DOM by the components, which isn't possible. Furthermore, since the components themselves already contain the style code, you would be adding a lot of size to the page by duplicating the style in a global stylesheet. In other words, you can't do it and it shouldn't be done.
Disappointing but ok
– Stefan
Nov 18 '18 at 22:57
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271642%2fangular-material-styles-in-a-single-stylesheet%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A call to the angular-material-theme() mixin will include theming only for components plus core (global) styles. Angular Material component style that is not part of theming is encapsulated and built in to the component and dynamically added to the DOM. There is no way to automatically include those styles in a single stylesheet. Even if you could do that, it is possible that everything might not work properly, plus you would also need to turn off the style tags inserted into the DOM by the components, which isn't possible. Furthermore, since the components themselves already contain the style code, you would be adding a lot of size to the page by duplicating the style in a global stylesheet. In other words, you can't do it and it shouldn't be done.
Disappointing but ok
– Stefan
Nov 18 '18 at 22:57
add a comment |
A call to the angular-material-theme() mixin will include theming only for components plus core (global) styles. Angular Material component style that is not part of theming is encapsulated and built in to the component and dynamically added to the DOM. There is no way to automatically include those styles in a single stylesheet. Even if you could do that, it is possible that everything might not work properly, plus you would also need to turn off the style tags inserted into the DOM by the components, which isn't possible. Furthermore, since the components themselves already contain the style code, you would be adding a lot of size to the page by duplicating the style in a global stylesheet. In other words, you can't do it and it shouldn't be done.
Disappointing but ok
– Stefan
Nov 18 '18 at 22:57
add a comment |
A call to the angular-material-theme() mixin will include theming only for components plus core (global) styles. Angular Material component style that is not part of theming is encapsulated and built in to the component and dynamically added to the DOM. There is no way to automatically include those styles in a single stylesheet. Even if you could do that, it is possible that everything might not work properly, plus you would also need to turn off the style tags inserted into the DOM by the components, which isn't possible. Furthermore, since the components themselves already contain the style code, you would be adding a lot of size to the page by duplicating the style in a global stylesheet. In other words, you can't do it and it shouldn't be done.
A call to the angular-material-theme() mixin will include theming only for components plus core (global) styles. Angular Material component style that is not part of theming is encapsulated and built in to the component and dynamically added to the DOM. There is no way to automatically include those styles in a single stylesheet. Even if you could do that, it is possible that everything might not work properly, plus you would also need to turn off the style tags inserted into the DOM by the components, which isn't possible. Furthermore, since the components themselves already contain the style code, you would be adding a lot of size to the page by duplicating the style in a global stylesheet. In other words, you can't do it and it shouldn't be done.
answered Nov 16 '18 at 21:31
G. Tranter
4,1011223
4,1011223
Disappointing but ok
– Stefan
Nov 18 '18 at 22:57
add a comment |
Disappointing but ok
– Stefan
Nov 18 '18 at 22:57
Disappointing but ok
– Stefan
Nov 18 '18 at 22:57
Disappointing but ok
– Stefan
Nov 18 '18 at 22:57
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271642%2fangular-material-styles-in-a-single-stylesheet%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
this sounds like @import ?
– Mike
Nov 15 '18 at 12:43
Yes, the styles are imported via '@include angular-material-theme($candy-app-theme);' which should add all components to the stylesheet. However the styles are still done via adding style tags
– Stefan
Nov 15 '18 at 12:51
Besides global styles material also uses local styles through
styleUrlslike github.com/angular/material2/blob/… So they are added as inline styles– yurzui
Nov 15 '18 at 13:11
1
@Mike take.ms/IWhoM
– yurzui
Nov 15 '18 at 14:10
2
github.com/angular/angular-cli/issues/…
– yurzui
Nov 15 '18 at 14:22