Add Support For CSS Variables
See original GitHub issueVersion
1.0.6
Reproduction
http://www.webpackbin.com/Vys62X0RZ
Steps to reproduce
Declare and use a CSS variable anywhere in a styled component.
Expected Behavior
Leading -
should remain intact so that browsers can properly identify variable declarations.
Actual Behavior
the first -
is being striped from the variable declaration causing browsers that support native CSS variables to view them as bad properties. If you go into dev tools and add the leading -
back in, everything works as expected.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
CSS Variables (Custom Properties) | Can I use... Support ...
CSS Variables (Custom Properties). - CR. Permits the declaration and usage of cascading variables in stylesheets. Usage % of. all users, all tracked ......
Read more >Using CSS custom properties (variables) - MDN Web Docs
Custom properties (sometimes referred to as CSS variables or cascading variables) are entities defined by CSS authors that contain specific ...
Read more >A user's guide to CSS variables – Increment: Frontend
CSS variables are currently supported for 93 percent of users globally. CSS variables are currently supported for 93 percent of users globally. If...
Read more >@supports with CSS Variables - CodePen
Adding Classes. In CodePen, whatever you write in the HTML editor is what goes within the <body> tags in a basic HTML5 template....
Read more >Browser Compatibility of CSS Variables (Custom Properties)
CSS Variables (Custom Properties) on Chrome is fully supported on 49-106, partially supported on None of the versions, and not supported on 4-48 ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The “polyfill” for css variables has some serious edge cases: https://github.com/MadLittleMods/postcss-css-variables#differences-from-postcss-custom-properties and the “Caveats” section below.
These all arise because it’s a PostCSS transform, and thus only has visibility into the CSS, not the DOM. This is part of the reason I am so opposed to postcss transforms being available in SC—they’re built for a different environment, and supporting/reproducing their limitations (or divergence from the specification as in this case) would weaken the whole proposal.
HOWEVER, if you’re feeling like a challenge 😉 Styled Components does have knowledge of both the DOM and the CSS rules, and so a true CSS custom properties polyfill is possible. I’ve had this in the back of my mind to implement for ages but it’s a lot of work. It would be amazing though!
In general, I’ve found that the combination of JS variables and inheritance using theming is everything I wanted CSS variables for anyway, so I haven’t missed them too much.
Wow that’s a straight up miss on my part. Sorry! On Tue., 18 Oct. 2016 at 8:14 am Brian Hough notifications@github.com wrote: