Usage for Themes
See original GitHub issueI am really excited about this project. One thing I haven’t wrapped my head around is how one could use these values to create “theme-able” components. Let’s say there are some variables that allow customization of a component - things like colors and fonts. Since the component’s css module has to import its values from some concrete file, I see no way how one could switch between two css files defining different values.
One could create two css modules that differ only in values, but then I would have to duplicate all the rules.
Basically, I wonder what would be the counterpart of the following SASS code:
// component.scss
.my-component {
background-color: $my-component-background-color;
}
// theme-a.scss
$my-component-background-color: green;
@import "my-component"
// theme-b.scss
$my-component-background-color: red;
@import "my-component"
Or is this simply something css module values are not supposed to solve?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:8
- Comments:34 (18 by maintainers)
Top Results From Across the Web
Use themes - Knowledge Base - HubSpot
A theme is a set of templates, modules, global content, and style settings that can be used to create a website. Themes can...
Read more >Using Themes
A WordPress Theme is a collection of files that work together to produce a graphical interface with an underlying unifying design for a...
Read more >Theme Definition & Meaning
The meaning of THEME is a subject or topic of discourse or of artistic representation. How to use theme in a sentence.
Read more >How to use themes on WordPress.com - YouTube
Welcome to WordPress.com! In this video, Mike Bal will discuss thow to use different themes on WordPress.com.Need more help?
Read more >What Are WordPress Themes - And How To Use Them?
One of the many reasons WordPress is so popular is the vast array of different themes you can choose for your site. But...
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
I’m thinking that variables could become another first class, local-by-default feature of CSS Modules.
Values do a good job of allowing you to be explicit about variable dependencies between modules, but it certainly doesn’t enforce it. I really like the guarantees that locally scoped classes and animations currently provide, and I think that variables are another candidate for this.
I propose that the following:
…would be compiled to this:
Then if you want to override this variable, you explicitly need to import it. Importing and overriding a variable could look something like this, perhaps:
Which, of course, is also compiled into this:
Thoughts?
Hey there! Even though that issue seems to approach its end of life… I just published a plugin to address this problem: https://github.com/andywer/postcss-theme
Maybe that’s some help for you, @SpencerCDixon?