Last active
March 4, 2023 07:27
-
-
Save vladdu/88f0c032fbca4ccca3456e92de7b80a7 to your computer and use it in GitHub Desktop.
TailwindCSS setup for skins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@layer base { | |
:root { | |
--color-text-main: 235,14,56; /* rgb values; can we have #fc,#10,#a0 ? */ | |
--color-text-accent: 197,100,134; | |
} | |
.some-class { | |
--color-text-main: 197,200,34; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function withOpacity(variableName) { | |
return ({opacityValue}) => { | |
if (opacityValue != undefined) { | |
`rgba(var(${variableName}), ${opacityValue})` | |
} | |
return `rgb(var(${variableName}))` | |
} | |
} | |
module.exports = { | |
theme: { | |
extend: { | |
textColor: { | |
skin: { | |
main: withOpacity('--color-text-main'), | |
accent: withOpacity('--color-text-accent'), | |
} | |
}, | |
backgroundColor: { | |
... | |
}, | |
gradientColorStops: { | |
hue: withOpacity('--color-fill') | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TailwindCSS setup for skins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! Anyway, the Tailwind 3.1 makes this obsolete
https://tailwindcss.com/blog/tailwindcss-v3-1#easier-css-variable-color-configuration