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.

Theming my own components (Alpha 9)

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:26 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
HeavenlyHostcommented, Oct 3, 2016

Also believe this to be related #887

2reactions
HeavenlyHostcommented, Oct 1, 2016

@dahaupt so are you saying that I need to create my own theme in order to theme my own components ? This is not my interpretation of the md file ! It reads as if all I need to do is import theming support and use the existing parameters ? If all I want to do is use an existing prebuilt theme and tap into the existing $primary palette how is this achievable. I do not agree that we should have to create a new theme, can we not simply apply an existing one and how do we do this ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Theming React Components - codeburst
Having a standard set of React components that you can reuse is great, but it presents a few problems, least of which is...
Read more >
Theming your own components - Angular Material
Theme your own components with Angular Material's theming system. You can use Angular Material's Sass-based theming system for your own custom components.
Read more >
Theming Bootstrap
Theming Bootstrap. Customize Bootstrap 4 with our new built-in Sass variables for global style preferences for easy theming and component changes. Introduction.
Read more >
Jetpack Compose theming - Android Developers
In this codelab you will learn how to use Jetpack Compose's theming APIs to style your application. We'll see how to customize colors,...
Read more >
Material Theming with MDC: Color - Medium
Material Theming is a way to customize Material Components to align with your brand. A Material theme includes color, typography and shape ...
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