components icon indicating copy to clipboard operation
components copied to clipboard

Theming my own components (Alpha 9)

Open HeavenlyHost opened this issue 10 years ago • 26 comments

Bug, feature request, or proposal:

Attempting to follow the guidelines for styling my own components based on Material, but simply can't get it to work, I am doing the following in the scss but it does not work. Importing theming and palette into my scss results in $primary not being found. What could I be doing wrong ? Am I not importing correctly ? How do I correctly import theming in my scss such that I can theme my own components.

At the top of my scss

@import 'node_modules/@angular/material/core/theming/_theming';

.someClass { background-color: md-color($primary); color: md-color($primary, default-contrast); // color: red; }

Then I get the following on compiling the SASS

Error: Undefined variable: "$primary"

Need Help

What is the expected behavior?

Need to be able to correctly theme my own components using material import via my scss

What is the current behavior?

Can't find $primary

What are the steps to reproduce?

Tried to pull together a plunker based on a material seed, find it here

plunker example

The plunker simply will not render if the code in myComp.component.scss remains as is, if the component theming is removed with the import commented and simply setting the color to red, the page will render correctly ???

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

Styling my own components based on material

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

Ng 2.0 final Material Alpha 9

Is there anything else we should know?

no

HeavenlyHost avatar Oct 01 '16 07:10 HeavenlyHost

Why is the .css needed in the first place? Angular includes the component css in each component and by importing the _theming.scss you generate your own themed .css with all the styles.

Isnt it possible to just remove those from the build?

tobakk avatar Oct 06 '16 08:10 tobakk

It is meant for those who are not using sass. If you are using sass, I think you can remove it by yourself.

vinagreti avatar Oct 06 '16 13:10 vinagreti

The problem with overlay is fixed in #1544- other than that, I think everything else should be covered by https://github.com/angular/material2/blob/master/docs/theming-your-components.md

jelbourn avatar Nov 04 '16 01:11 jelbourn

@jelbourn Link is broken

crosshopes avatar Mar 05 '17 08:03 crosshopes

@crosshopes New link for the theming guide is at:

https://github.com/angular/material2/blob/master/guides/theming-your-components.md.

Also available here:

https://material.angular.io/guide/theming-your-components

willshowell avatar Mar 07 '17 12:03 willshowell

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.