I'm using tailwind v3 and according to the docs, it's possible to override existing colors using the tailwind.config
file
https://tailwindcss.com/docs/customizing-colors
module.exports = {
theme: {
extend: {
colors: {
gray: {
"50": "#fcefed",
"100": "#fadedb",
"200": "#f7ceca",
"300": "#f5bdb8",
"400": "#f2ada6",
"500": "#ef9d94",
"600": "#ed8c82",
"700": "#ea7c71",
"800": "#e86b5f",
"900": "#e55b4d"
}
}
}
}
I want to override the color palette when a user clicks on a button. How can I override it during runtime? Ideally, I could use the same convention as the tailwind config file, something like that:
//user click on a button
const onColorsPicked = () => {
const colors = {
"50": "#fcefed",
"100": "#fadedb",
"200": "#f7ceca",
"300": "#f5bdb8",
"400": "#f2ada6",
"500": "#ef9d94",
"600": "#ed8c82",
"700": "#ea7c71",
"800": "#e86b5f",
"900": "#e55b4d"
}
//what would be the best approach to implement this function? it's even possible?
overrideTailwindColor("gray", colors)
}
Not sure if the just-in-time-mode could help or not (https://v2.tailwindcss.com/docs/just-in-time-mode)
What would be the best approach to do that? There are any CSS variables I can override instead? Or I should get all the classes that tailwind could generate and override them? (sounds like a huge overkill)