To define a custom color in tailwind.config.js #88
-
To define a custom color in tailwind.config.js, why not use a simpler designation like the one below (without
|
Beta Was this translation helpful? Give feedback.
Answered by
theodorusclarence
Jan 18, 2022
Replies: 2 comments 7 replies
-
That’s to utilize the CSS Variables itself With CSS variables we can use something like this theme switcher without additional config |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
theodorusclarence
-
On my side work this function. Can you @theodorusclarence advise how can I use it inside /* 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'), // it does not work!!!
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That’s to utilize the CSS Variables itself
With CSS variables we can use something like this theme switcher without additional config