Skip to content

Instantly share code, notes, and snippets.

@vladdu
Last active March 4, 2023 07:27
Show Gist options
  • Save vladdu/88f0c032fbca4ccca3456e92de7b80a7 to your computer and use it in GitHub Desktop.
Save vladdu/88f0c032fbca4ccca3456e92de7b80a7 to your computer and use it in GitHub Desktop.
TailwindCSS setup for skins
@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;
}
}
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')
}
}
}
TailwindCSS setup for skins
@vladdu
Copy link
Author

vladdu commented Jun 18, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment