Replies: 3 comments
-
This seems to be explained in the Tailwind CSS documentation https://tailwindcss.com/docs/customizing-colors#using-css-variables |
Beta Was this translation helpful? Give feedback.
-
I think it's overcomplicating things. The current approach makes it easy to change and customize with some constraints and generates a full color palette. If you want to use CSS variables, feel free to refactor, but I would prefer not to make it the default. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your opinion! Maybe someone would be interested in experimenting with CSS variables ) Also, some useful information about syntax for modern color declarations https://dev.to/alvaromontoro/the-ultimate-guide-to-css-colors-2020-edition-1bh1#rgb-rgba /* globals.css */
:root {
--tw-color-blue-vivid-100: 230 246 255; /* #E6F6FF; hsl(202, 100%, 95%) */
}
h1,
.h1 {
@apply text-primary-100/50;
} // tailwind.config.js
function withOpacityValue(variable) {
return ({ opacityValue }) => {
if (opacityValue === undefined) {
return `rgb(var(${variable}))`
}
return `rgb(var(${variable}) / ${opacityValue})`
}
}
module.exports = {
theme: {
extend: {
colors: {
primary: {
100: withOpacityValue('--tw-color-blue-vivid-100'),
}
}
typography: (theme) => ({
DEFAULT: {
css: {
color: theme('colors.primary.100/50'), // Herу it does not work!!! only `color: theme('colors.primary.100')`
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Will the following method give an advantage for defining a custom color?
References: https://github.com/adamwathan/tailwind-css-variable-text-opacity-demo
Beta Was this translation helpful? Give feedback.
All reactions