How to use semantic color names with specific namespaces #17705
-
I am currently working with the new tailwind v4, and trying to implement some custom colours specific to a theme variable namespace and can't seem to find my way around this using the v4 configuration. Essentially, I'd like to replicate something like this in tailwind v4. Please note that the code below is not an actual working code but just meant to convey my intended use.
The intended result is to be able to use utility classes like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Use the utility-specific namespaces like to have semantic colors: @theme {
--text-color-default: …;
--background-color-default: …;
--border-color-default: …;
} Use standard CSS rules per each "theme": @theme {
…
}
@layer theme {
@media (prefers-color-scheme: dark) {
:root {
--text-color-default: …;
--background-color-default: …;
--border-color-default: …;
}
}
.red {
--text-color-default: …;
--background-color-default: …;
--border-color-default: …;
}
} |
Beta Was this translation helpful? Give feedback.
Use the utility-specific namespaces like to have semantic colors:
Use standard CSS rules per each "theme":