-
Notifications
You must be signed in to change notification settings - Fork 9
Using config('colors') in SASS color functions #72
Comments
Using Tailwind's colors in your Sass is definitely tricky/impossible :/ I would recommend just maintaining a duplicate list of colors in both a Sass variables file and your Tailwind color palette if you want to access them from both places. Annoying to update two places but shouldn't really be too painful in practice. Another option is to use Sass to generate CSS3 variables like:
Then you can reference those same Sass variables in the other UI framework:
Then in Tailwind, you can set your color palette to use those CSS3 variables instead of real values:
Then you could add the https://github.com/postcss/postcss-custom-properties This would allow you to keep all of the variables just defined in your Sass and reuse them in Tailwind. Sort of convoluted but that's the best way I can think to do it. |
I think two color lists will do it. Thanks! |
Or inject color list with sass option like #79. |
@adamwathan you solution working nice, but there is problem with negative Margin. Tailwind generate Any suggestion? Thanks! |
@adamwathan I'm using negative values for margin for now, but maybe existing better solution... |
Seems like I'm commenting on an old thread, but just in case anyone else needed some sort of tailwind config to scss variables utility, I whipped up a quick node script that takes in the tailwind config file and creates a scss variables file based on the defined configuration. The code below just creates a file based on the colors defined but can be adjusted to any properties defined in the config file.
From my tailwind configuration file, it created this scss file:
From here, you can just import this file in any of your scss files. |
Pretty frustrated that it's not working natively, but thanks for workarounds, guys! |
Found a solution here: https://medium.com/@josh.pospisil/good-post-and-a-great-starting-point-d4b9fae0df63 It's using a SASS function declared in webpack config which can read the Tailwind config file. Looks like using Edit: I got it working, I summarized it in a gist: https://gist.github.com/nicooprat/2753f44875d2894183a8d588d6e411c0 Edit: updated the gist to make it work with Tailwind 1.0 |
You could also use this tool, it will export your configs to sass/less/stylus etc :) https://www.npmjs.com/package/tailwindcss-export-config |
I'm using tailwind with a third party UI framework. Within the tailwind config file I would like to set SASS color variables for that framework, e.g. something like this:
This won't work since
config('colors.blue')
is not available when the SASS color function is applied. So what is the best way to do so?The text was updated successfully, but these errors were encountered: