Material-components-web: Regression: CSS runtime variable theming for tabs is broken

Created on 6 May 2019  路  8Comments  路  Source: material-components/material-components-web

I think I've tracked it down to this line which no longer respects css variables, only the SASS.

https://github.com/material-components/material-components-web/pull/4675/files#diff-bebfa5920069adc8cf8c7d36390da5f6R130

Most helpful comment

Oh awesome. Well, personally I feel that css vars are freaking amazing (and I'll never run SASS again). I'd love to see the library move into a direction of official support for them, and as always, willing to help get it there. I've been using them exlusively for 2 years with little to no issues, just minor things like this that pop up.

All 8 comments

4688 will fix this to some extent.

But as per the current state most of the components we do not support theming using only CSS variables because of CSS limitations. For example, we use rgba() function in most of the places get less opaque color, for example, in components like text field, drawer, chips, checkbox etc.

But, support for CSS variables for theming is something that is in our radar.

Pointing out something that was previously supported / working that now isn't, which is a breaking change for people that rely on it. I've had a ton of success using only css variables. This old PR I had open was more for brainstorming, but the idea this guy posted would solve the color mixin problem and allow css vars to work everywhere. https://github.com/material-components/material-components-web/pull/3145#issuecomment-406811295

So far we've included sass variable / mixin changes & component API changes as breaking changes. Since we don't fully support theming using CSS variable we haven't consider this as breaking change.

Another alternative approach to support CSS variables is to generate CSS variables for each primary color variant (ranging from 100 to 800) and reference it in the places where we need to mix with alpha. For example, primary color with alpha .34: --mdc-theme-primary-300: rgba(purple, .34);)

Did you see the comment above? You can specify the colors and comma separated rgb for the variables which would allow you to do it all dynamically.

I did take a look at the issue that you linked last year. Now I remember that I made a working prototype with that approach as proof-of-concept. /theme_alpha_variables_issue3066 :)

At that time, we decided not to change the color value format just to support this feature.

Oh awesome. Well, personally I feel that css vars are freaking amazing (and I'll never run SASS again). I'd love to see the library move into a direction of official support for them, and as always, willing to help get it there. I've been using them exlusively for 2 years with little to no issues, just minor things like this that pop up.

I created epic bug to track all the things related to CSS variables: #4709

Awesome, thanks :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trimox picture trimox  路  4Comments

yapryntsev picture yapryntsev  路  3Comments

jimyhdolores picture jimyhdolores  路  3Comments

broros picture broros  路  3Comments

robzenn92 picture robzenn92  路  4Comments