You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
update theming docs to be more clear about how to structure your theme file to be usable across custom components #1786
it would generate unnecessary(since they are already in the main file) classes, like elevation, inside my components's encapsulated css.. which is bad.
The way I see it, your _custom-theme.scss should import and contain something along these lines
thanks to this, you'd be able to import _custom-theme.scss anywhere and be able to use palette functions as well as your variables without it generating any duplicated material classes
Reacted by eagle-dan1349, Benjamin Charity, Rene Vallecillo V, Michael Irwin, Aleš, Netanel Draiman, Will Howell, Vijay Sarathy and Arthur
You need to update to the latest version, and put a scss file in your src dir, not @angular/material. Make sure to add the sass file to angularcli.json
On Feb 8, 2017, 11:08 PM -0500, 김동욱 ***@***.***>, wrote:
/* angular material theming */ @import ***@***.***/material/core/theming/all-theme'; @include mat-core(); $app-primary: mat-palette($mat-blue, A400, A100, A700); $app-accent: mat-palette($mat-pink, A200, A100, A400); $app-warn: mat-palette($mat-red); $app-theme: mat-light-theme($app-primary, $app-accent, $app-warn); @include angular-material-theme($app-theme);
now it works!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub (#1786 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/AEPIEitWt2Qnr8p5hFC-75v7-YenFtaBks5rapFZgaJpZM4KthhC).
Also @wbhob no, it's not "fixed", still if you took the code from https://material.angular.io/guide/theming and put it in _my-theme.scss and then tried importing it in your custom component(to be able to use the colors you just defined, or md-*()/mat-*() functions generally), I would generate the whole angular theme encapsulated for the said component, that's like 30kb of styles inside EACH of your components.
@fxck Yeah, we are all waiting for @angular to cut a new version. Their tests are passing, and they haven't released a new beta in TWO MONTHS. I, personally, am getting pretty furious at the lack of transparency.
Trust me, the situation is amazing compared to what it was couple of months ago. Also now you have the material2-builds repo, which helps a ton. #3075 (comment)
The tilde ~ represents the path and doesn't actually work. You'll have to build in the absolute path (./node_modules/@angular/...). Also, I don't think remote origins are supported, so just include them in index.htnl.
Finally, this is not the place for support requests, please post on stack overflow or elsewhere @sumnercreations
AFAIK the two guides on theming on the docs site should provide decent guidance on custom theming and for theming your own components. Feel free to open a new issue if there are any specific problems.
@jelbourn I still think it's misleading, wrong, and unnecessarily increasing people's bundle sizes, the specific problem I initially described still stands
@import'~@angular/material/theming';
// Plus imports for other components in your app.// Include the base styles for Angular Material core. We include this here so that you only// have to load a single css file for Angular Material in your app.@includemat-core();
// Define the palettes for your theme using the Material Design palettes available in palette.scss// (imported above). For each palette, you can optionally specify a default, lighter, and darker// hue.$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent: mat-palette($mat-pink, A200, A100, A400);
// The warn palette is optional (defaults to red).$candy-app-warn: mat-palette($mat-red);
// Create the theme object (a Sass map containing all of the palettes).$candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent, $candy-app-warn);
// Include theme styles for core and each component used in your app.// Alternatively, you can import and @include the theme mixins for each component// that you are using.@includeangular-material-theme($candy-app-theme);
import it in my component's scss file with @import
// or whatever is the path to my theme@import'../../assets/theme';
I do not need to do literally anything else, just this single line is gonna generate all the general m2 styles (elevation, ripple, cdk stuff)
and this is gonna happen for every single component you import your theme in!!
Youll notice that the elevations classes are all actually different, and this is generated to create the elevation effect. It is not applied to every component, just available as a class when you need it.
Wilson Hobbs
CEO/Founder/Developer at Canal
11th Grade at The Lovett School
Personal Information
E-mail: wilsonhobbs1@gmail.com
Cell: (404) 719-3252
Website: www.wilsonhobbs.com (https://www.wilsonhobbs.com)
Twitter/Instagram/Facebook: @wbhob
Canal Information
E-mail: wilson@getcanal.com
Web: www.getcanal.com (https://www.getcanal.com/)
Twitter/Instagram/Facebook: @getcanal
On Apr 10, 2017, 4:34 AM -0400, Aleš ***@***.***>, wrote:
@jelbourn (https://github.com/jelbourn) I still think it's misleading and wrong, and unnecessarily increasing people's bundle sizes, the specific problem I initially described still stands
if I follow the directions of https://material.angular.io/guide/theming, that is:
create my theme.scss, with this content
@import ***@***.***/material/theming'; // Plus imports for other components in your app. // Include the base styles for Angular Material core. We include this here so that you only // have to load a single css file for Angular Material in your app. @include mat-core(); // Define the palettes for your theme using the Material Design palettes available in palette.scss // (imported above). For each palette, you can optionally specify a default, lighter, and darker // hue. $candy-app-primary: mat-palette($mat-indigo); $candy-app-accent: mat-palette($mat-pink, A200, A100, A400); // The warn palette is optional (defaults to red). $candy-app-warn: mat-palette($mat-red); // Create the theme object (a Sass map containing all of the palettes). $candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent, $candy-app-warn); // Include theme styles for core and each component used in your app. // Alternatively, you can import and @include the theme mixins for each component // that you are using. @include angular-material-theme($candy-app-theme);
import it in my component's scss file with @import
// or whatever is the path to my theme @import '../../assets/theme';
now I do not need to do literally anything else, just this single line is gonna generate all the general m2 styles (elevation, ripple, cdk stuff)
and this is gonna happen for every single component you import your theme in!!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub (#1786 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/AEPIEjp-b9Muuq1mu8qEdCK8N8ikmw9iks5ruemJgaJpZM4KthhC).
*.component.scss only includes this line @import '../../assets/theme';
theme.scss is c&p from theming guide
@import'~@angular/material/theming';
// Plus imports for other components in your app.// Include the base styles for Angular Material core. We include this here so that you only// have to load a single css file for Angular Material in your app.@includemat-core();
// Define the palettes for your theme using the Material Design palettes available in palette.scss// (imported above). For each palette, you can optionally specify a default, lighter, and darker// hue.$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent: mat-palette($mat-pink, A200, A100, A400);
// The warn palette is optional (defaults to red).$candy-app-warn: mat-palette($mat-red);
// Create the theme object (a Sass map containing all of the palettes).$candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent, $candy-app-warn);
// Include theme styles for core and each component used in your app.// Alternatively, you can import and @include the theme mixins for each component// that you are using.@includeangular-material-theme($candy-app-theme);
both are printed in the root component
since I've removed all other ng-cli styles (the default app.component.css and styles.css), there are only two <style> tags appended to head, for app-foo and for app-bar
You shouldn't have to import he style sheet into every component... it's just globally applied when you put it into your style sheet included in angular-cli.json
Wilson Hobbs
CEO/Founder/Developer at Canal
11th Grade at The Lovett School
Personal Information
E-mail: wilsonhobbs1@gmail.com
Cell: (404) 719-3252
Website: www.wilsonhobbs.com (https://www.wilsonhobbs.com)
Twitter/Instagram/Facebook: @wbhob
Canal Information
E-mail: wilson@getcanal.com
Web: www.getcanal.com (https://www.getcanal.com/)
Twitter/Instagram/Facebook: @getcanal
On Apr 10, 2017, 6:54 AM -0400, Aleš ***@***.***>, wrote:
No, that is not true.
I have two empty components generated with ng-cli, FooComponent, BarComponent,
import { Component, OnInit } from ***@***.***/core'; @component({ selector: 'app-foo', // bar-foo templateUrl: './foo.component.html', // bar.component.html styleUrls: ['./foo.component.scss'] // bar.component.scss }) export class FooComponent implements OnInit { // BarComponent constructor() { } ngOnInit() { } }
*.component.scss only includes this line @import '../../assets/theme';
theme.scss is c&p from themeing guide
@import ***@***.***/material/theming'; // Plus imports for other components in your app. // Include the base styles for Angular Material core. We include this here so that you only // have to load a single css file for Angular Material in your app. @include mat-core(); // Define the palettes for your theme using the Material Design palettes available in palette.scss // (imported above). For each palette, you can optionally specify a default, lighter, and darker // hue. $candy-app-primary: mat-palette($mat-indigo); $candy-app-accent: mat-palette($mat-pink, A200, A100, A400); // The warn palette is optional (defaults to red). $candy-app-warn: mat-palette($mat-red); // Create the theme object (a Sass map containing all of the palettes). $candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent, $candy-app-warn); // Include theme styles for core and each component used in your app. // Alternatively, you can import and @include the theme mixins for each component // that you are using. @include angular-material-theme($candy-app-theme);
both are printed in the root component
since I've removed all other ng-cli styles (the default app.component.css and styles.css), there are only two <style> tags appended to head, for app-foo and for app-bar
this is content of the first one
this is content of the second one
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (#1786 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/AEPIErCFfDUzBsiwnLnca1_DSbPoti9zks5rugpigaJpZM4KthhC).
........... that's the whole point, you need to import your theme.scss, if you want to utilise ANY material2 sass helper functions, color palettes, your theme
the guide should say that you should define your theme in theme.scss, but instead doing @include angular-material-theme($candy-app-theme); in the same file, your should import this theme.scss in your main/global style and call the angular-material-theme function there, only then you can safely import your theme.scss in any component without it generating duplicated files
I don't understand why you need it in each component, it's all already globally available
Wilson Hobbs
CEO/Founder/Developer at Canal
11th Grade at The Lovett School
Personal Information
E-mail: wilsonhobbs1@gmail.com
Cell: (404) 719-3252
Website: www.wilsonhobbs.com (https://www.wilsonhobbs.com)
Twitter/Instagram/Facebook: @wbhob
Canal Information
E-mail: wilson@getcanal.com
Web: www.getcanal.com (https://www.getcanal.com/)
Twitter/Instagram/Facebook: @getcanal
Oh that makes sense, still don't see why you need to use functions in individual components, just perform them globally.
Wilson Hobbs
CEO/Founder/Developer at Canal
11th Grade at The Lovett School
Personal Information
E-mail: wilsonhobbs1@gmail.com
Cell: (404) 719-3252
Website: www.wilsonhobbs.com (https://www.wilsonhobbs.com)
Twitter/Instagram/Facebook: @wbhob
Canal Information
E-mail: wilson@getcanal.com
Web: www.getcanal.com (https://www.getcanal.com/)
Twitter/Instagram/Facebook: @getcanal
On Apr 10, 2017, 7:08 AM -0400, Aleš ***@***.***>, wrote:
the guide should say that you should define your theme in theme.scss, but instead doing @include angular-material-theme($candy-app-theme); in the same file, your should import this theme.scss in your main/global style and call the angular-material-theme function there, only then you can safely import your theme.scss in any component without it generating duplicated files
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (#1786 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/AEPIEvL5UIFBfrOwsPioiUkFB1XKT0IOks5rug3LgaJpZM4KthhC).
I don't understand why are you commenting if you don't understand. :)
If you use webpack (or ng-cli), there's no such thing as globally available sass functions and/or variables, you HAVE to @import them in every single component you need them:
The only thing you can use, are the already generated css classes (ie. elevation), if they are either in your head tag, or in your root component with disabled encapsulation. But that still only allows you to do:
<divclass="mat-elevation-z1"></div>
and not:
<divclass="foo"></div>
.foo {
@includemat-elevation(1);
}
Reacted by Michael Prentice, Vijay Sarathy and Mila Rodriguez
Activity
wbhob commentedon Dec 23, 2016
This is fixed here: https://material.angular.io/guide/theming. This guide is really easy and I got started in 60 seconds.
Happy holidays!
dehypnosis commentedon Feb 9, 2017
why builder say 'No mixin named md-core'?
wbhob commentedon Feb 9, 2017
dehypnosis commentedon Feb 9, 2017
i am on latest of master branch, and it seemes that the prefix of names are changed from 'md' to 'mat'.
is it right?
dehypnosis commentedon Feb 9, 2017
now it works!
wbhob commentedon Feb 9, 2017
dehypnosis commentedon Feb 9, 2017
really? thank you for your help!
wbhob commentedon Feb 9, 2017
artworkad commentedon Feb 14, 2017
For me mat-* does not work, but md-* does
fxck commentedon Feb 14, 2017
That's because beta.1 still uses
md-*, only the latest*-buildsreleases havemat-*.fxck commentedon Feb 14, 2017
Also @wbhob no, it's not "fixed", still if you took the code from https://material.angular.io/guide/theming and put it in
_my-theme.scssand then tried importing it in your custom component(to be able to use the colors you just defined, ormd-*()/mat-*()functions generally), I would generate the whole angular theme encapsulated for the said component, that's like 30kb of styles inside EACH of your components.wbhob commentedon Feb 15, 2017
@fxck Yeah, we are all waiting for @angular to cut a new version. Their tests are passing, and they haven't released a new beta in TWO MONTHS. I, personally, am getting pretty furious at the lack of transparency.
fxck commentedon Feb 15, 2017
Trust me, the situation is amazing compared to what it was couple of months ago. Also now you have the
material2-buildsrepo, which helps a ton. #3075 (comment)ccheraa commentedon Feb 16, 2017
I updated to beta-2 and
md-*is not working anymore, had to usemat-*.wbhob commentedon Feb 16, 2017
That is correct and by design.
1 remaining item
wbhob commentedon Mar 7, 2017
The tilde ~ represents the path and doesn't actually work. You'll have to build in the absolute path (./node_modules/@angular/...). Also, I don't think remote origins are supported, so just include them in index.htnl.
Finally, this is not the place for support requests, please post on stack overflow or elsewhere @sumnercreations
jelbourn commentedon Apr 9, 2017
Closing this as it's drifted a bit off-topic.
AFAIK the two guides on theming on the docs site should provide decent guidance on custom theming and for theming your own components. Feel free to open a new issue if there are any specific problems.
fxck commentedon Apr 10, 2017
@jelbourn I still think it's misleading, wrong, and unnecessarily increasing people's bundle sizes, the specific problem I initially described still stands
if I follow the directions of https://material.angular.io/guide/theming, that is:
theme.scss, with this content@importI do not need to do literally anything else, just this single line is gonna generate all the general m2 styles (elevation, ripple, cdk stuff)
and this is gonna happen for every single component you import your
themein!!that's why it's important to separate
which is what you can safely import in any component, because it itself doesn't generate anything, from
which is what you want to include only once in your root component
wbhob commentedon Apr 10, 2017
fxck commentedon Apr 10, 2017
No, that is not true.
I have two empty components generated with ng-cli,
FooComponent,BarComponent,*.component.scssonly includes this line@import '../../assets/theme';theme.scssis c&p from theming guideboth are printed in the root component
since I've removed all other ng-cli styles (the default app.component.css and styles.css), there are only two <style> tags appended to head, for
app-fooand forapp-barthis is content of the first one

this is content of the second one

wbhob commentedon Apr 10, 2017
fxck commentedon Apr 10, 2017
........... that's the whole point, you need to import your
theme.scss, if you want to utilise ANY material2 sass helper functions, color palettes, your themehttps://material.angular.io/guide/theming-your-components

if you do this, where

@import 'src/unicorn-app-theme.scss'is thisyou are gonna 28kb of unnecessary styles (after minification) included in your component
fxck commentedon Apr 10, 2017
the guide should say that you should define your theme in
theme.scss, but instead doing@include angular-material-theme($candy-app-theme);in the same file, your should import thistheme.scssin your main/global style and call theangular-material-themefunction there, only then you can safely import yourtheme.scssin any component without it generating duplicated fileswbhob commentedon Apr 10, 2017
wbhob commentedon Apr 10, 2017
fxck commentedon Apr 10, 2017
I don't understand why are you commenting if you don't understand. :)
If you use webpack (or ng-cli), there's no such thing as globally available sass functions and/or variables, you HAVE to
@importthem in every single component you need them:webpack/sass-loader#218
webpack/sass-loader#211
..and million other issues.
The only thing you can use, are the already generated css classes (ie. elevation), if they are either in your head tag, or in your root component with disabled encapsulation. But that still only allows you to do:
and not:
codercatdev commentedon May 7, 2018
@fxck thank you so much!!! Same functionality


Old
New
angular-automatic-lock-bot commentedon Sep 8, 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.