[theme] How to use collor-palette to configure theme | sass
See original GitHub issueThis is not really a bug but rather help request - hopefully there is a quick answer.
I would like to configure my theme using material color palette (which can be found in @material/theme/color-palette
I am able to access the colors like this
@use "@material/theme" as theme;
// or @use "@material/theme/color-palette" as theme;
body {
background-color: theme.$red-500;
}
but then how to configure $primary
or $secondary
colors
@use "@material/theme" as theme;
@use "@material/theme" with (
$primary: theme.$red-500,
$secondary: theme.$pink-500,
);
This throws Error: This module was already loaded, so it can't be configured using "with".
I’ve also tried
@use "@material/theme" as theme;
theme.$primary: theme.$red-500;
@use "material-components-web"; // custom file importing single components
body {
background-color: theme.$red-500;
}
And I do get background red but mdc components are not changed.
How can I set material $primary
,$secondary
or other colors using material color palette?
Thanks for help!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Create a color theme mixin with Sass - YouTube
A look at the CUBE CSS methodology in action · Give your site a fantastic color scheme fast · Create a fun animated...
Read more >Theme and Color Scheme — SASS Way - Medium
In the SCSS file, you need to define your themes and color schemes. Both themes and color schemes are arrays. You can add...
Read more >Access Theme Color Values With Sass - Egghead.io
Manage the color palette used in your stylesheets by creating a map of variables and a function to access the values by key....
Read more >Dealing with Color Schemes in Sass - SitePoint
Many websites have styles set up as color modules. This articles considers how Sass can be used to make color schemes DRY and...
Read more >Switchable Color Schemes in SASS
1. Setting/changing inline CSS based on a configurable color code · 2. Setting/changing a SASS variable based on a class · 3. Using...
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
Try this:
I think this would be a documentation feature we should expand upon. Either explaining how to do it like above, or refactoring code to make it more feasible.
Move the import after the use.
@import url()
is a runtime CSS statement, not a Sass@import
module.This will transpile to the following CSS:
I just tested and verified that it works. If you continue to have trouble though, feel free to open a new issue so we can keep this one focused on the theme color palette documentation problem.